0

I need to search-and-replace on a docx file, i used this project : Simple DocX Editor in Native C#

at first time it doesn't work because i have as operating system windows 8 so i made some modification :

Shell shell = new Shell();
Folder archive = GetShell32NameSpace(archiveFile);//shell.NameSpace(Path.GetFullPath(archiveFile));
Folder extractFolder = GetShell32NameSpace(unArchiveFolder);//shell.NameSpace(Path.GetFullPath(unArchiveFolder));


public static Shell32.Folder GetShell32NameSpace(Object folder)
{
     Type shellAppType = Type.GetTypeFromProgID("Shell.Application");
     Object shell = Activator.CreateInstance(shellAppType);
     return (Shell32.Folder)shellAppType.InvokeMember("NameSpace", System.Reflection.BindingFlags.InvokeMethod, null, shell, new object[] { folder });
}

Now it work for me well, but when i deployed in windows server 2012, it gives me this error

enter image description here

Can someone gives me some informations or any help to solve this problem! thanks in advance

i m sorry for my bad english!

leppie
  • 115,091
  • 17
  • 196
  • 297
Omar AMEZOUG
  • 958
  • 2
  • 14
  • 38

1 Answers1

0

Your problem seems to be related to the same issue as per reference a windows shell interface using .net 4.0

Type shellAppType = Type.GetTypeFromProgID("Shell.Application");
dynamic shell = Activator.CreateInstance(shellAppType);

There is an SDK from Microsoft called Office Open XML which can be used to manipulate .docx and other MS Office formats. It does not required Office to be installed on the server.

Community
  • 1
  • 1
user2316116
  • 6,726
  • 1
  • 21
  • 35