none
wpf如何解压文件 RRS feed

答案

  • 你好,

    .NET 4.5中,增加了解压缩Zip文件的类库,你需要引用System.IO.Compression.FileSystem 程序集,详细内容请参看:http://msdn.microsoft.com/en-us/library/ms404280(v=vs.110).aspx

    这里有一个例子:

    using System;
    using System.IO;
    using System.IO.Compression;
    
    namespace ConsoleApplication
    {
        class Program
        {
            static void Main(string[] args)
            {
                string startPath = @"c:\example\start";
                string zipPath = @"c:\example\result.zip";
                string extractPath = @"c:\example\extract";
    
                ZipFile.CreateFromDirectory(startPath, zipPath);
    
                ZipFile.ExtractToDirectory(zipPath, extractPath);
            }
        }
    }

    谢谢!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年3月7日 8:05
    版主
  • 你好,

    .NET 4.5之前,.NET Framework没有现成的类库可以解压ZIP文件。有可以解压GZIP的。http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream(v=vs.100).aspx

    如果在.NET 4.0中想解压ZIP文件,我推荐你使用7ZIP。不过需要你先安装,下载地址:

    http://www.7-zip.org/download.html

    我写了一个例子,用7ZIP来解压ZIP文件的,你可以参考下,

    	var processStartInfo = new ProcessStartInfo();
    	processStartInfo.FileName = @"C:\Program Files\7-Zip\7z.exe";
            processStartInfo.Arguments = @"e C:\test.7z";
            Process.Start(processStartInfo);

    谢谢!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年3月12日 6:47
    版主

全部回复

  • 你好,

    .NET 4.5中,增加了解压缩Zip文件的类库,你需要引用System.IO.Compression.FileSystem 程序集,详细内容请参看:http://msdn.microsoft.com/en-us/library/ms404280(v=vs.110).aspx

    这里有一个例子:

    using System;
    using System.IO;
    using System.IO.Compression;
    
    namespace ConsoleApplication
    {
        class Program
        {
            static void Main(string[] args)
            {
                string startPath = @"c:\example\start";
                string zipPath = @"c:\example\result.zip";
                string extractPath = @"c:\example\extract";
    
                ZipFile.CreateFromDirectory(startPath, zipPath);
    
                ZipFile.ExtractToDirectory(zipPath, extractPath);
            }
        }
    }

    谢谢!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年3月7日 8:05
    版主
  • 使用的.net 4.0没有这个
    2014年3月12日 0:31
  • 你好,

    .NET 4.5之前,.NET Framework没有现成的类库可以解压ZIP文件。有可以解压GZIP的。http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream(v=vs.100).aspx

    如果在.NET 4.0中想解压ZIP文件,我推荐你使用7ZIP。不过需要你先安装,下载地址:

    http://www.7-zip.org/download.html

    我写了一个例子,用7ZIP来解压ZIP文件的,你可以参考下,

    	var processStartInfo = new ProcessStartInfo();
    	processStartInfo.FileName = @"C:\Program Files\7-Zip\7z.exe";
            processStartInfo.Arguments = @"e C:\test.7z";
            Process.Start(processStartInfo);

    谢谢!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年3月12日 6:47
    版主