contre / Windows-API-Code-Pack-1.1

Windows API Code Pack 1.1
Other
161 stars 46 forks source link

ERROR using Microsoft.WindowsAPICodePack.Shell; --> Missing using directive #36

Closed GH-Djeff closed 3 years ago

GH-Djeff commented 3 years ago

Hello, i try to run the following Powershell Script ########################################### _**using Microsoft.WindowsAPICodePack.Shell; using Microsoft.WindowsAPICodePack.Shell.PropertySystem;

string filePath = @"D:\temp\example.docx"; 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();**_ ######################################################################### I have the following error

ParserError: Line | 1 | using Microsoft.WindowsAPICodePack.Shell; | ~ | Missing using directive

Can you help me please.

Regards, Djeff

anhellwig commented 3 years ago

Your code looks like C# code to me, not like a PowerShell script.

contre commented 3 years ago

This isn't a tested use for the library so I won't be of much help here.

GH-Djeff commented 3 years ago

Thank you all for your help. I'll be back with a new code