Protected void button#click (object sender, EventArgs e)
{
// Compression
String the_rar;
RegistryKey the_Reg;
Object the_Obj;
String the_Info;
ProcessStartInfo the_StartInfo;
Process the_Process;
Try
{
The_Reg = Registry. ClassesRoot. OpenSubKey (@ "Applications \ WinRAR.exe \ Shell \ Open \ Command ");
The_Obj = the_Reg.GetValue ("");
The_rar = the_Obj.ToString ();
The_Reg.Close ();
The_rar = the_rar.Substring (1, the_rar.Length-7 );
The_Info = "a-r-ep1" + "a.rar" + @ "1 \*";
The_StartInfo = new ProcessStartInfo ();
The_StartInfo.FileName = the_rar;
The_StartInfo.Arguments = the_Info;
The_StartInfo.WindowStyle = ProcessWindowStyle. Hidden;
The_StartInfo.WorkingDirectory = @ "C: \ rar"; // The initial directory of the process.
//
The_Process = new Process ();
The_Process.StartInfo = the_StartInfo;
The_Process.Start ();
Response. Write ("compressed successfully ");
}
Catch (Exception ex)
{
Response. Write (ex. ToString ());
}
}
Protected void Button2_Click (object sender, EventArgs e)
{
// Extract
String the_rar;
RegistryKey the_Reg;
Object the_Obj;
String the_Info;
ProcessStartInfo the_StartInfo;
Process the_Process;
Try
{
The_Reg = Registry. ClassesRoot. OpenSubKey (@ "Applications \ WinRar.exe \ Shell \ Open \ Command ");
The_Obj = the_Reg.GetValue ("");
The_rar = the_Obj.ToString ();
The_Reg.Close ();
The_rar = the_rar.Substring (1, the_rar.Length-7 );
The_Info = @ "x" + @ "a.rar" + "" + @ "\";
The_StartInfo = new ProcessStartInfo ();
The_StartInfo.FileName = the_rar;
The_StartInfo.Arguments = the_Info;
The_StartInfo.WindowStyle = ProcessWindowStyle. Hidden;
The_StartInfo.WorkingDirectory = @ "C: \ rar"; // gets or sets the initial directory of the process to be started.
The_Process = new Process ();
The_Process.StartInfo = the_StartInfo;
The_Process.Start ();
While (! The_Process.HasExited) // wait until the decompression is completed
{
}
// File. Delete (filePath + fileName );
Response. Write (@ "decompressed ");
}
Catch (Exception ex)
{
Response. Write (ex. ToString ());
}
}