I saw a lot of sample code to add folder connection dynamically with sdk. But I got a requirement that the users want to have set of predefined folder connections into their favorite before they create the project. Is there any code snippet I can refer to?
This is the good idea.
And also your suggestion is one of the requirement for me to do so as well together with checking the existing project's folder connection to validate.
As an additional, they also want to add those connections into favorites.
I do manage to add folder into folder connection with below code
var folderToAdd = ItemFactory.Instance.Create(folderpath);
await QueuedTask.Run(() => Project.Current.AddItem(folderToAdd as IProjectItem);
One thing I can't manage to do is that can't find a way to add the folder path into favorites and read the existing paths from favorites.
And I am thinking whether it is good way to update [profile path]\AppData\Roaming\Esri\ArcGISPro\Favorites\favorites.json file as well.
I saw the command but there is precondition mentioned in it to call that command, [esri_geodatabase_addFolderConnectionToFavoritesButton] , not sure how to use that or is that correct one as well.
What do you recommend?
The ability to add folder connections to the "Favorites" is slated to be available with 2.5 release. But in the meantime, you can definitely re-use the esri_geodatabase_addFolderConnectionToFavoritesButton button in your customization.