C# WinRAR 自解压问题

来源:百度知道 编辑:UC知道 时间:2024/05/25 05:36:21
这是我在C# Winfrom里 写的一个关于制作“自解压格式”压缩包的方法:
private bool WinRAR()
{
string strtxtPath = "C:\\freezip\\free.txt";
string strzipPath = "C:\\freezip\\free.zip";
System.Diagnostics.Process Process1 =
new System.Diagnostics.Process();
Process1.StartInfo.FileName = "Winrar.exe";
Process1.StartInfo.CreateNoWindow = true;

strzipPath = "C:\\freezip\\free";//默认压缩方式为rar
Process1.StartInfo.Arguments = " a -s -sfx Setup=frees.exe "+ strzipPath + " " + strtxtPath ;
Process1.Start();
if (Process1.HasExited)
{
int iExitCode = Process1.ExitCode;
if (iExitCode == 0)
{
return false;
}
else
{
return false;
}

/// <summary>
/// 调用winRAR
/// </summary>
/// <param name="name">压缩包名</param>
/// <param name="dirPath">打包源路径</param>
/// <param name="zipPath">压缩包存放位置</param>
/// <param name="smarkPath">备注文件 主意路径存在的空格</param>>
/// <returns></returns>
public string winRAR(string dirPath, string zipPath, string smarkPath, string defaultValue)
{
try
{
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe");
string WinRarPath = key.GetValue("").ToString();
if (!WinRarPath.Equals(""))
{
System