Home > Backend Development > C++ > How Can I Use Microsoft.WindowsAPICodePack to Set Extended File Properties?

How Can I Use Microsoft.WindowsAPICodePack to Set Extended File Properties?

Barbara Streisand
Release: 2024-12-27 16:26:11
Original
943 people have browsed it

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:

  • Microsoft.WindowsAPICodePack-Shell
  • Microsoft.WindowsAPICodePack-Core

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;
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template