[C#] FileZip类|即使文件已经存在也提取. [英] [C#] FileZip class | Extract even if file already exist.
本文介绍了[C#] FileZip类|即使文件已经存在也提取.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
即使文件已经存在,也可以使用FileZip类提取文件吗? atm我解压缩我的zip文件时出现错误,提示该文件已存在.
ZipFile.ExtractToDirectory(Application.StartupPath + @" ,Application.StartupPath);
File.Delete(Application.StartupPath + @" );
解决方案
如果库中没有"overwrite existing"标志,那么首先要检查并删除它.
尝试执行以下操作:
ZipArchive zipArchive = 新 ZipFile.OpenRead(Application.StartupPath + @" \ patch001.zip"); foreach (ZipArchiveEntry条目 in zipArchive.Entries中) { entry.ExtractToFile(Application.StartupPath + entry.Name, true ); } zipArchive.Dispose();
希望这会有所帮助.
Hi, Is it possible to extract a file with the FileZip class even if the file already exist? atm i''m getting an error when extracting my zip file that the file does already exist.
ZipFile.ExtractToDirectory(Application.StartupPath + @"\patch001.zip", Application.StartupPath); File.Delete(Application.StartupPath + @"\patch001.zip");解决方案If the library doesn''t have an ''overwrite existing'' flag, the easy thing to do, is check and delete it first.
Hi,
Try to do this:
ZipArchive zipArchive = new ZipFile.OpenRead(Application.StartupPath + @"\patch001.zip"); foreach (ZipArchiveEntry entry in zipArchive.Entries) { entry.ExtractToFile(Application.StartupPath + entry.Name, true); } zipArchive.Dispose();
Hope this helps.
这篇关于[C#] FileZip类|即使文件已经存在也提取.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文