ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Core Namespace / FavoritesManager Class / AddFavorite Method / AddFavorite(Item,Boolean) Method
The item to add to the favorite collection. For example a folder connection or a toolbox.
Is the new favorite to be added to all new projects.

In This Topic
    AddFavorite(Item,Boolean) Method
    In This Topic
    Adds an item to the favorites collection.
    Syntax
    public Favorite AddFavorite( 
       Item item,
       bool addToAllNewProjects
    )
    Public Overloads Function AddFavorite( _
       ByVal item As Item, _
       ByVal addToAllNewProjects As Boolean _
    ) As Favorite

    Parameters

    item
    The item to add to the favorite collection. For example a folder connection or a toolbox.
    addToAllNewProjects
    Is the new favorite to be added to all new projects.

    Return Value

    The favorite item. Null if the item cannot be added as a favorite.
    Remarks
    An item can only exist once in the favorite collection. If the item already exists in the favorites collection, then no additional item is added. However the Favorite.IsAddedToAllNewProjects property will be updated according to the addToAllNewProjects value.

    You should always check CanAddAsFavorite before passing an item to this method.

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also