GetSensitivityLabels

DocumentProperties.GetSensitivityLabels method

Gets an array of sensitivity labels from the custom document properties (Microsoft Information Protection SDK Metadata).

public ISensitivityLabel[] GetSensitivityLabels()

Examples

The following code shows how to move the sensitivity labels information from the custom document properties to the modern SensitivityLabels collection:

[C#]
using (Presentation pres = new Presentation("SomePresentation.pptx"))
{
    // Get sensitivity labels from the custom document properties
    ISensitivityLabel[] mipSensitivityLabels = pres.DocumentProperties.GetSensitivityLabels();

    ISensitivityLabelCollection sensitivityLabels = pres.SensitivityLabels;
    foreach (var sensitivityLabel in mipSensitivityLabels)
    {
        // Add label to the collection
        // Here you can add a check for the validity of the label information (the label is available, etc)
        sensitivityLabels.Add(sensitivityLabel);
    }

    pres.Save("SensitivityLabel.pptx", SaveFormat.Pptx);
}

See Also