error: "Microsoft.WindowsAPICodePack.Shell.PropertySystem.PropertySystemException Unable to get writable property store for this property."

-2

I have created dotnet application which is updating metadata (e.g. "Title" property) of XLSX file.

I am using Microsoft.WindowsAPICodePack.Shell library in my application...which is perfectly updating metadata of that file on development environment.

But on production server that application is not working.

It is giving error like.....

Microsoft.WindowsAPICodePack.Shell.PropertySystem.PropertySystemException (0x80004005): Unable to get writable property store for this property.

Development and Production environment is having same OS installed. Visual Studio and office installed on delvelopment environment. But not on production environment.

Does any one have idea on this?

c#
.net
xlsx
asked on Stack Overflow Jan 2, 2020 by Ruchi Shah • edited Jan 2, 2020 by Mohan Singh

1 Answer

0

Add following NuGet packages to your project:

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

Read and Write Properties

using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;

string filePath = @"yourfilepath";
var file = ShellFile.FromFilePath(filePath);

// Read and Write:

string[] oldAuthors = file.Properties.System.Author.Value;
string oldTitle = file.Properties.System.Title.Value;

file.Properties.System.Author.Value = new string[] { "Author #1", "Author #2" };
file.Properties.System.Title.Value = "Example Title";

// Alternate way to Write:

ShellPropertyWriter propertyWriter =  file.Properties.GetPropertyWriter();
propertyWriter.WriteProperty(SystemProperties.System.Author, new string[] { "Author" });
propertyWriter.Close();
answered on Stack Overflow Jan 2, 2020 by Vishal Parmar • edited Jan 2, 2020 by Vishal Parmar

User contributions licensed under CC BY-SA 3.0