I need use 7zip in C#. Without console, just with 7zSharp.dll ? + I find some data here
http://7zsharp.codeplex.com/releases/view/10305 ,
but I don't know how to use it( - I could create .bat(.cmd) file, but I need throught dll file) Exactly: I need extract .7z file with key)
Extracting 7zip files Locate the desired zip file. Right-click it and select 7-Zip > Extract Here. The file will be extracted to the folder containing the zipped file. Select Extract files to change the extraction folder.
While both are compression programs, 7-Zip can compress files into a wider range of format types, including 7z. WinRAR can only compress into RAR or ZIP formats. However, both can decompress a wide variety of format types. Also, 7-Zip is open source and free, while WinRAR costs over $30 for a lifetime license.
WinRAR can open 7Z (7-Zip) extension by default.
To unzip a single file or folder, open the zipped folder, then drag the file or folder from the zipped folder to a new location. To unzip all the contents of the zipped folder, press and hold (or right-click) the folder, select Extract All, and then follow the instructions.
Download the standalone console version from 7zip.com and add it to your project.
You need those 3 Files added in the project:
Don't forget to say Copy to Output Directory in it's preferences.
Extract an archive:
public void ExtractFile(string sourceArchive, string destination)
{
string zPath = "7za.exe"; //add to proj and set CopyToOuputDir
try
{
ProcessStartInfo pro = new ProcessStartInfo();
pro.WindowStyle = ProcessWindowStyle.Hidden;
pro.FileName = zPath;
pro.Arguments = string.Format("x \"{0}\" -y -o\"{1}\"", sourceArchive, destination);
Process x = Process.Start(pro);
x.WaitForExit();
}
catch (System.Exception Ex) {
//handle error
}
}
Create an archive:
public void CreateZip(string sourceName, string targetArchive)
{
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = "7za.exe";
p.Arguments = string.Format("a -tgzip \"{0}\" \"{1}\" -mx=9", targetArchive, sourceName);
p.WindowStyle = ProcessWindowStyle.Hidden;
Process x = Process.Start(p);
x.WaitForExit();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With