1

Possible Duplicate:
How do I create 7-Zip archives with .NET?

How can we integrate 7-zip archiving library in a C#.NET application. I am working on an application that need to have an extraction utility for stored zip files, for which I guess 7Zip's DLL will be the best.

Can any one tell me how can I use it to integrate into my application. My need is to open a Fileopen dialog on a button click->browse for the zip file->Then extract it and save the files somewhere.

I tried using SevenZipSharp Library, here is the code:

private void button1_Click(object sender, EventArgs e)
    {
        SevenZip.SevenZipExtractor.SetLibraryPath(@"F:\PARADOX\WFAST\WFAST\Res\7z.dll");
        SevenZip.SevenZipExtractor ext = new SevenZip.SevenZipExtractor(@"C:\Users\user\Desktop\stitch.zip");
        System.IO.Directory.CreateDirectory("C:/Users/user/Desktop/Stitch");
        ext.BeginExtractArchive("C:/Users/user/Desktop/Stitch");

    }

But get error: Can not load 7-zip library or internal COM error! Message: failed to load library.

Community
  • 1
  • 1
Cyberpks
  • 1,401
  • 6
  • 21
  • 51
  • 1
    You may wish to reconsider your terminology in future - you're not "implementing" a 7-zip library - you're integrating the existing 7-zip library into your application. The way you've worded it at the moment makes it sound like you'd be writing the archiving code yourself in a compatible way... – Jon Skeet Sep 27 '12 at 06:01
  • You may also wish to reconsider using StackOverflow, since it's clear nobody here has read your question to the end nor had any hands-on experience with SevenZipSharp. But hey, at least FIVE separate people took the time to mark your question as a duplicate. That was obviously the best response we could have had. – Derf Skren Dec 23 '14 at 03:09

1 Answers1

-3

If you are looking for 7zip, of course just use 7 zip. I don't really understand how there could be a question to that end. Why you would need to wrap it in some .NET app is unclear, since 7zip has both a nice gui and command line interface.

If on the other hand you actually want to write a simple .NET application that can handle compressed files, you might start with the System.IO.Compression namespace, which has been part of the .NET standard library for a number of releases. http://msdn.microsoft.com/en-us/library/system.io.compression.aspx

Sam Grondahl
  • 2,397
  • 2
  • 20
  • 26
  • 1
    But ZipFile, ZipArchive only available in .NET 4.5 or later – linquize Sep 27 '12 at 06:23
  • Can't use it, as the program on which I am working will make a zip file that can be found corrupt by .NET's `System.IO.Compression`. The resultant zip file would be a kind of encrypted file that can be extracted by 7zip easily, but not with .NET's compression library. – Cyberpks Sep 27 '12 at 08:03
  • Ok, then take my first suggestion and use 7zip, then pipe back in. That is clearly the best solution, as suggested in the duplicate mentioned above. See http://stackoverflow.com/questions/206323/how-to-execute-command-line-in-c-get-std-out-results and http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx if you need help with that also. – Sam Grondahl Sep 27 '12 at 14:46