I'm creating ASP.NET Web Application. I need in it to extract some '7z' files.
My code:
SevenZipExtractor.SetLibraryPath(@"<some_path>\7z.dll");
var zipExtractor = new SevenZipExtractor(zipPath);
zipExtractor.ExtractArchive(path);
SetLibraryPath, according to SevenZipSharp documentation, should resolve the problem, but it doesn't.
During my tests in console app everything works fine but when I'm trying to run my web Application I get "Can not load 7-zip library or internal COM error! Message: failed to load library.". In console app it's easier because dll files can be placed in Debug folder and it works. Web Application is handled by IIS Express which I guess is the problem.
It turned out that 7z.dll needs to be in temporary folder created by IIS. It can be accessed using via Assembly:
Using that we can copy original 7z.dll to the assembly directory and set SevenZipSharp library path like that:
Note that overwrite is set to true. It is because sometimes assembly happens to be the same that one before.