0
下面的代码在创建zip文件时工作正常,但创建的文件有一个文件夹IIS部署>>> WebService ...然后是文本文件,而不仅仅是文本文件。从多个文件创建zip文件
如何将文本文件添加到zip文件?
ZipFile z = ZipFile.Create("C:\\IIS Deploy\\WebServiceTest\\WebServiceTest\\Accident.zip");
//initialize the file so that it can accept updates
z.BeginUpdate();
//add the file to the zip file
z.Add("C:\\IIS Deploy\\WebServiceTest\\WebServiceTest\\test1.txt");
z.Add("C:\\IIS Deploy\\WebServiceTest\\WebServiceTest\\test2.txt");
z.Add("C:\\IIS Deploy\\WebServiceTest\\WebServiceTest\\test3.txt");
//commit the update once we are done
z.CommitUpdate();
//close the file
z.Close();
如果我正确理解你的问题,我认为解决的办法可能是创建压缩文件,并添加内容,而不一个完全合格的路径。可能还有一个选项可以在Add方法上添加文件(不考虑其包含的路径)。 –
我试过并得到文件错误..应该指定路径我猜 –
我认为@codebased答案中提供的解决方案是一个很好的路径。 –