Home > Backend Development > C++ > How Can I Modify Extended File Properties (Like Company) in Word or PDF Documents Using .NET?

How Can I Modify Extended File Properties (Like Company) in Word or PDF Documents Using .NET?

DDD
Release: 2025-01-05 13:17:41
Original
447 people have browsed it

How Can I Modify Extended File Properties (Like Company) in Word or PDF Documents Using .NET?

Setting Extended File Properties in .NET

If you need to modify the Company field value or other extended file properties within Word or PDF documents, here's how you can do it using .NET:

  1. Install NuGet Packages:
    Add the following NuGet packages to your project:

    • Microsoft.WindowsAPICodePack-Shell
    • Microsoft.WindowsAPICodePack-Core
  2. Read and Write Properties:
    In your C# code, use the Microsoft.WindowsAPICodePack.Shell and Microsoft.WindowsAPICodePack.Shell.PropertySystem namespaces to read and write file properties. Here's an example:
using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;

string filePath = @".\example.docx";
var file = ShellFile.FromFilePath(filePath);

// Read the old properties
string[] oldAuthors = file.Properties.System.Author.Value;
Copy after login

The above is the detailed content of How Can I Modify Extended File Properties (Like Company) in Word or PDF Documents Using .NET?. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template