C# 4.0 在C中使用7zip.exe压缩多个文件#
我必须使用7zip.exe将多个文件压缩到一起。我有两个文件的路径,比如file1和file2。我使用以下命令附加这两个路径。 字符串filetozip=file1+“\”“+file2+”;并执行以下操作C# 4.0 在C中使用7zip.exe压缩多个文件#,c#-4.0,process,7zip,C# 4.0,Process,7zip,我必须使用7zip.exe将多个文件压缩到一起。我有两个文件的路径,比如file1和file2。我使用以下命令附加这两个路径。 字符串filetozip=file1+“\”“+file2+”;并执行以下操作 Process proc = new Process(); proc.StartInfo.FileName = @"C:\Freedom\7-Zip\7z.exe"; proc.StartInfo.UseShellExecute = false
Process proc = new Process();
proc.StartInfo.FileName = @"C:\Freedom\7-Zip\7z.exe";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.Arguments = string.Format(" a -tzip \"{0}\" \"{1}\" -mx=9 -mem=AES256 -p\"{2}\" ", destZipFile, filetozip , zipPassword);
proc.Start();
proc.WaitForExit();
if (proc.ExitCode != 0)
{
throw new Exception("Error Zipping Data File : " + proc.StandardError.ReadToEnd());
}
filetozip作为上面的参数传递。上面的代码工作不正常。我正在获取proc.ExitCode=1。这是追加文件路径的正确方法。字符串filetozip=file1+“\”“+file2+”;正确的方法?我可以有一个或多个文件。使用的分隔符是什么?要创建的命令行如下所示 加上所需的开关(引用参数并用空格分隔)
或者是一些可能有用的编码功能您必须使用7zip.exe吗?从.Net 3.0开始,内置了一个zip类:建议我只使用7zip。请告诉我如何使用。是的,我有7zip.exe@SteveWellensI,上面的代码由@Lifestyle ByAtom回答