Tag: uncompress

如何在C#中提取rar文件?

我想使用cmd shell提取.rar文件,所以我写了这段代码: string commandLine = @”c:\progra~1\winrar\winrar ec:\download\TestedU.rar c:\download”; ProcessStartInfo PSI = new ProcessStartInfo(“cmd.exe”); PSI.RedirectStandardInput = true; PSI.RedirectStandardOutput = true; PSI.RedirectStandardError = true; PSI.UseShellExecute = false; Process p = Process.Start(PSI); StreamWriter SW = p.StandardInput; StreamReader SR = p.StandardOutput; SW.WriteLine(commandLine); SW.Close(); 它第一次工作正常,第二次没有显示任何东西。

如何将zip文件内容提取到.NET 4.5中的文件夹中

以下问题的答案似乎概述了如何使用System.IO.Commpression.ZipFile.ExtractToDirectory方法调用来提取文件。 在添加对System.IO.Compression的引用时,.NET 4.5中似乎不存在“ZipFile”。 如何从.NET 4.5中的* .zip文件中提取文件? 如何使用C#4.0从文件夹解压缩所有.Zip文件,而不使用任何OpenSource Dll? 这似乎显示了如何压缩文件。 但我正在寻找相反的方向。 在.NET 4.5中压缩文件 甚至这个问题在源代码中引用了“ZipFile”。 但我似乎无法找到这门课。 如何从C#.NET 4.5中的zip存档中提取特定目录? 编辑: 请注意7z.exe(来自7zip包)是如何工作的。 必须与.NET和7zip发生冲突。 ZipFile现在似乎工作正常。 private void extract_Click(object sender, EventArgs e) { string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location; exePath = @”C:\test”; // path during troubleshooting ////var cmd1 = “cd \”” + exePath + “\””; ////ExecuteCommand(cmd1, 100, exePath); //var cmd2 = “\”” + […]