I referenced to my project the dll file: SevenZipSharp.dll
Then in the top of Form1 I added:
using SevenZip;
Then I created a function that I'm calling from a button click event:
private void Compress()
{
string source = @"C:\Users\bout0_000\AppData\Local\Diagnostic_Tool_Blue_Screen\Diagnostic Tool Blue Screen\SF_02-08-13";
string output = @"D:\Zipped.zip";
SevenZipCompressor compressor = new SevenZipCompressor();
compressor.ArchiveFormat = OutArchiveFormat.Zip;
compressor.CompressionMode = CompressionMode.Create;
compressor.TempFolderPath = System.IO.Path.GetTempPath();
compressor.CompressDirectory(source, output);
}
I used a breakpoint and the error is on the line:
compressor.CompressDirectory(source, output);
But I'm getting an error:
Cannot load 7-zip library or internal COM error! Message: DLL file does not exist
But I referenced the dll already, so why this error? How can I fix it?
Solved the problem:
private void Compress()
{
string source = @"C:\Users\bout0_000\AppData\Local\Diagnostic_Tool_Blue_Screen\Diagnostic Tool Blue Screen\SF_02-08-13";
string output = @"D:\Zipped.zip";
SevenZipExtractor.SetLibraryPath(@"C:\Program Files\7-Zip\7z.dll");
SevenZipCompressor compressor = new SevenZipCompressor();
compressor.ArchiveFormat = OutArchiveFormat.Zip;
compressor.CompressionMode = CompressionMode.Create;
compressor.TempFolderPath = System.IO.Path.GetTempPath();
compressor.CompressDirectory(source, output);
}
Downloading error: The error of 7-zip file may also occur while downloading from the internet due to slow connection or bandwidth etc. that can also lead to CRR error. File header corruption: File header is the place to contain the file name, size, and extension, etc. These details help in accessing the file.
I've checked everything, I clicked on properties, I have all the permission boxes ticked, other folders are able to be compressed no problem, I can compress the folder using 7-Zip but it isn't able to be uploaded to any websites or anything.
Locate the file or folder that you want to compress. Right-click the file or folder, point to Send To, and then click Compressed (zipped) Folder. A new compressed folder is created. To rename it, right-click the folder, click Rename, and then type the new name. This thread is locked.
Step 1: Use antivirus to clear the virus in the software. You may use quick heal, Norton, or AGV antivirus. Step 2: Then, browse the 7-zip official website to get the tool again. But, before installing the new one, be sure to uninstall the previous version. Always remember to get the same version that you used to compress the file.
You're probably missing the internal COM component that is required. If you check the InnerException, it should give you a good idea of what's missing. Copy these to your working directory and you should be set.
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