Tag: 拉链

删除的zip文件会导致e.Data.GetData(“FileContents”)抛出exception

我正在尝试在我的WPF应用程序中为从zip存档拖动的文件实现一个处理程序。 处理程序应获取文件内容以供进一步处理。 我的环境:安装了Windows7,7-zip,Visual Studio 2012 Express,.Net 4.5 以下是一个简单的MainWindow应用程序的代码,用于演示此问题: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); AllowDrop= true; Drop += onDrop; } private void onDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(“FileContents”)) { var fileContents = e.Data.GetData(“FileContents”); //get file contents… } } } 当我将zip存档中包含的文件拖到我的Window时,对e.Data.GetData(“FileContents”)的调用将使用以下callstack抛出System.ArgumentException(“Argument out of Range”): System.Windows.DataObject.OleConverter.GetDataInner(formatetc, medium) System.Windows.DataObject.OleConverter.GetDataFromOleHGLOBAL(format, aspect, index) System.Windows.DataObject.OleConverter.GetDataFromBoundOleDataObject(format, […]

从C#中的多个内存文件创建Zip归档文件

当文件当前在内存中时,有没有办法创建包含多个文件的Zip存档? 我想保存的文件实际上只是文本,并存储在我的应用程序的字符串类中。 但我想将多个文件保存在一个独立的存档中。 它们都可以在归档的根目录中。 能够使用SharpZipLib做到这一点会很高兴。