Home >Backend Development >C++ >How Can I Use Microsoft.WindowsAPICodePack to Set Extended File Properties?
Setting Extended File Properties Using Microsoft.WindowsAPICodePack
Extended file properties, such as Company information, provide valuable metadata for Word and PDF documents. While retrieving these properties is straightforward using shell32.dll, setting them poses a greater challenge. This article explores how to leverage Microsoft.WindowsAPICodePack to effectively alter extended file properties.
Getting Started
To start, install the following NuGet packages:
Reading and Writing Properties
Once the packages are installed, you can access and modify properties using the following code:
using Microsoft.WindowsAPICodePack.Shell; using Microsoft.WindowsAPICodePack.Shell.PropertySystem; // Get file path string filePath = @"C:\temp\example.docx"; // Load file var file = ShellFile.FromFilePath(filePath); // Get current properties string[] oldAuthors = file.Properties.System.Author.Value;
The above is the detailed content of How Can I Use Microsoft.WindowsAPICodePack to Set Extended File Properties?. For more information, please follow other related articles on the PHP Chinese website!