ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Core Namespace / Item Class / CanEdit Method
Example

In This Topic
    CanEdit Method (Item)
    In This Topic
    Indicates if metadata is editable for the item. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public bool CanEdit()
    Public Function CanEdit() As Boolean

    Return Value

    true if the metadata can be edited
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Item: Set the metadata of an item: SetXML
    await QueuedTask.Run(() =>
    {
      var xml = System.IO.File.ReadAllText(@"E:\Data\Metadata\MetadataForFeatClass.xml");
      //Will throw InvalidOperationException if the metadata cannot be changed
      //so check "CanEdit" first
      if (featureClassMetadataItem.CanEdit())
        featureClassMetadataItem.SetXml(xml);
    });
    
    
    Item: Check the metadata can be edited: CanEdit
    bool canEdit1;
    //Call CanEdit before calling SetXml
    await QueuedTask.Run(() => canEdit1 = metadataItemToCheck.CanEdit());
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also