程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> 關於C# >> C#程序 調用WinRAR壓縮軟件實現文件打包函數

C#程序 調用WinRAR壓縮軟件實現文件打包函數

編輯:關於C#
 

//patch: 文件/文件夾路徑,rarPatch: rar存儲路徑,rarName: 保存的文件夾名稱
public void RARsave(string patch, string rarPatch, string rarName)
{
String the_rar;
RegistryKey the_Reg;
Object the_Obj;
String the_Info;
ProcessStartInfo the_StartInfo;
Process the_Process;
try
{
the_Reg = Registry.ClassesRoot.OpenSubKey(@"WinRAR");
the_Obj = the_Reg.GetValue("");
the_rar = the_Obj.ToString();
the_Reg.Close();
the_rar = the_rar.Substring(1, the_rar.Length - 7);
if (!Directory.Exists(patch))
{
Directory.CreateDirectory(patch);
}
//the_Info = " a " + rarName + " " + @"C:Test?70821.txt"; 文件壓縮
the_Info = " a " + rarName + " " + patch + " -r";
the_StartInfo = new ProcessStartInfo();
the_StartInfo.FileName = "WinRar";//the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
//打包文件存放目錄
the_StartInfo.WorkingDirectory = rarPatch;
the_Process = new Process();
the_Process.StartInfo = the_StartInfo;
the_Process.Start();
the_Process.WaitForExit();
the_Process.Close();
}
catch (Exception ex)
{
throw ex;
}
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved