I have use the below snippet code to make zip folder by Ionic.zip
:
string lastFolder = packageSpec.FolderPath.Split('\\')[packageSpec.FolderPath.Split('\\').Length - 1];
string zipRoot = packageSpec.FolderPath + "\\Zip" + lastFolder;
string fileName = zipRoot + "\\" + lastFolder + ".zip";
Logging.Log(LoggingMode.Prompt, "Spliting to zip part...");
if (!Directory.Exists(zipRoot))
Directory.CreateDirectory(zipRoot);
ZipFile zip = new ZipFile();
zip.AddDirectory(packageSpec.FolderPath, zipRoot);
zip.MaxOutputSegmentSize = 200 * 1024 * 1024; // 200 MB segments
zip.Save(fileName);
it works fine to create multiple zip part but make unexpected nested folder as following desc below: if the variables are :
FolderPath = C:\MSR\Temp\Export_1
zipRoot = C:\MSR\Temp\Export_1\ZipExport_1
fileName= C:\MSR\Temp\Export_1\ZipExport_1\Export_1.zip
My source is like the image below:
1- is my source folder with it's staff to zip
2- is zip folder will contains 1 zip.AddDirectory(packageSpec.FolderPath, zipRoot);
But I am ending up with :
so these folders MSR->Temp->Export_1->ZipExport_1->ZipExport1
are extera which means Export_1.zip should have directly source folder not that nested extra folders .
does anybody knows how I can change that snippet code to do it?
thanks in advance.