Update or add metadata properties satisfying a predicate
The SetProperties is used to update or add metadata. You can easily add metadata to photos, pdfs or you can update or add data to mp3 files. This code sample actually combines two operations: add and update. If an existing property satisfies the specified predicate its value is updated. If there is a known property missing in a metadata package that satisfies the predicate it is added to the appropriate package.
The code snippet below demonstrates a basic usage scenario of the SetProperties method.
// Constants.InputVsdx is an absolute or relative path to your document. Ex: @"C:\Docs\source.vsdx"using(Metadatametadata=newMetadata(Constants.InputVsdx)){// Set the value of each property that satisfies the predicate:// property contains the date/time the document was created OR modifiedvaraffected=metadata.SetProperties(p=>p.Tags.Contains(Tags.Time.Created)||p.Tags.Contains(Tags.Time.Modified),newPropertyValue(DateTime.Now));Console.WriteLine("Properties set: {0}",affected);metadata.Save(Constants.OutputVsdx);}
As a result, we update all existing metadata properties containing the date the document was created/updated. If a metadata package doesn’t contain such properties but they are meant to be in its structure they are added.
For more information on supported features of the GroupDocs.Metadata search engine please refer to the following articles:
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.