无法从Web应用程序解压缩文件?

时间:2012-08-22 07:15:55

标签: c# asp.net-mvc compression unzip

我正在尝试使用Ionic.Zip Dll解压缩下载的文件。

我的代码适用于Windows应用程序,但它无法在我的Web应用程序中运行。

代码运行时没有错误,但是当我检查文件夹时,仍然有Ziped下载的文件没有提取。

Web应用程序需要做什么特殊事情吗?

 private void MyExtract()
        {
            string zipToUnpack = "C:\\Users\\Shaun\\Desktop\\RescommTestData\\downloadfile.zip";
            string unpackDirectory = "ExtractedFiles"; //used to create a file to extract files to
            using (ZipFile zip1 = ZipFile.Read(zipToUnpack))
            {
                // here, we extract every entry, but we could extract conditionally
                // based on entry name, size, date, checkbox status, etc.  
                foreach (ZipEntry e in zip1)
                {
                    e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);
                    // e.Extract(ExtractExistingFileAction.OverwriteSilently);
                }

            }
            try
            {
                //File.Delete("C:\\Users\\Shaun\\Desktop\\downloadfile.zip");
                MessageBox.Show("Unpacked photos and data file into ExtractedFiles folder in bin/Debug");
            }
            catch (Exception)
            {
                MessageBox.Show("Could not delete ZIP!");
                Environment.Exit(1);
            }

0 个答案:

没有答案
相关问题