我遇到了麻烦,我得到了这个代码:
DirectoryInfo di = new DirectoryInfo(dir);
FileInfo[] rgFiles = di.GetFiles();
DirectoryInfo[] d = di.GetDirectories();
if(rgFiles != null && d != null) {
foreach (FileInfo fi in rgFiles)
{
foreach (DirectoryInfo dii in d)
{
using (ZipFile zip = ZipFile.Read(locateZipFile()))
{
zip.AddFile(fi.FullName, "");
zip.AddDirectory(dii.FullName,dii.Name);
toolStripStatusLabel1.Text = "Inserting " + fi.Name;
toolStripStatusLabel1.Text = "Inserting " + dii.Name + " and all of it's contents";
MessageBox.Show("Inserted the file " + fi.Name);
MessageBox.Show("Inserted the folder " + dii.Name + " and all contents in it.");
zip.Save();
}
}
}
一切都很好,但是当我尝试在 zip 中添加一个名称相同的文件时,它不会覆盖它,我想要它......关于我如何做到这一点的任何想法?谢谢。