C# packaged zip files can call ready-made third-party DLLs, which can get twice the result with half the effort, and the dll is completely free, download address: SharpZipLib
After downloading and unzipping, copy ICSharpCode.SharpZipLib.dll to the directory of the current project (if you are lazy, you can copy it directly to the bin\Debug directory of the current project), right-click on the project reference opened by VS to add the reference ICSharpCode.SharpZipLib.dll
nuget command:
Then, right-click on the project opened by VS to create a new class, name it ZipHelper.cs, empty all the code in the class, copy the following code, and paste it:
target compressed file,You cannot zip folder subdirectories, otherwise the error will be as follows:
The process cannot access the file 'D:\\Test\\ITSVSE.zip' because it is being used by another process.
To use it, after referencing using ZipOneCode.ZipProvider externally, you can call ZipHelper.CreateZip(@"D:\Temp\forzip", @"D:\Temp2\forzip.zip").
Note: Before calling, consider paying attention to some abnormal situations, such as whether the source file path exists.
MVC returns the package file:
(End)
|