莫因!
using (ZipFile zip = new ZipFile())
{
// add this map file into the "images" directory in the zip archive
zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");
// add the report into a different directory in the archive
zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files");
zip.AddFile("ReadMe.txt");
zip.Save("MyZipFile.zip");
}
此示例将MyZipFile.zip存储在“C:\ Program Files(x86)\ IIS Express”中,我在网上找不到任何简单示例有没有办法更改该路径?我怀疑我有权访问我的虚拟主机。
答案 0 :(得分:11)
更改保存方法或声明时的路径。
ZipFile zip = new ZipFile("C:\\MyFile.Zip");
或
using (ZipFile zip = new ZipFile())
{
// add this map file into the "images" directory in the zip archive
zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");
// add the report into a different directory in the archive
zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files");
zip.AddFile("ReadMe.txt");
zip.Save("C:\\MyZipFile.zip");
}
获取更多帮助DotNetZip