First join the namespace
UsingMicrosoft. Win32;
UsingSystem. runtime. interopservices;
UsingSystem. diagnostics;
Compression Method:
{
Function anonymous ()
{
Function anonymous ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ closed_text_180905 '). style. display = 'none'; document. getelementbyid ('Code _ open_image_180905 '). style. display = 'inline'; document. getelementbyid ('Code _ open_text_180905 '). style. display = 'inline ';
}
}
}
} "Style =" display: none; "id =" code_closed_image_180905 "> {
Function anonymous ()
{
Function anonymous ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ open_text_180905 '). style. display = 'none'; getelementbyid ('Code _ closed_image_180905 '). style. display = 'inline'; getelementbyid ('Code _ closed_text_180905 '). style. display = 'inline ';
}
}
}
} "Id =" code_open_image_180905 ">
// Compression
String strrar;
Registrykey rkreg;
Object OBJ;
String strinfo;
Processstartinfo psiinfo;
Process pprocess;
Try
{
Rkreg = Registry. classesroot. opensubkey ( @" Applications \ winrar.exe \ shell \ open \ command " );
OBJ = Rkreg. getvalue ( "" );
Strrar = OBJ. tostring ();
Rkreg. Close ();
Strrar = Strrar. substring ( 1 , Strrar. Length - 7 );
Strinfo = " A-R-EP1 test.rar " + Lbltree. Text + @" RAR/test1.txt " + Lbltree. Text + @" RAR " ; // Here is the RAR compression Command Format (which can be expanded by yourself)
Psiinfo = New Processstartinfo ();
Psiinfo. filename = Strrar;
Psiinfo. Arguments = Strinfo;
Psiinfo. windowstyle = Processwindowstyle. hidden;
Psiinfo. workingdirectory = Lbltree. Text + " RAR " ;; // Gets or sets the initial directory of the process to be started.
Pprocess = New Process ();
Pprocess. startinfo = Psiinfo;
Pprocess. Start ();
Response. Write ( " <Font color = Red> compression successful </font> " );
}
Catch (Exception ex)
{
Response. Write (ex. tostring ());
}
Decompression method:
// Extract
String strrar;
Registrykey rkreg;
Object OBJ;
String strinfo;
Processstartinfo psiinfo;
Process pprocess;
Try
{
Rkreg = Registry. classesroot. opensubkey ( @" Applications \ winrar.exe \ shell \ open \ command " );
OBJ = Rkreg. getvalue ( "" );
Strrar = OBJ. tostring ();
Rkreg. Close ();
Strrar = Strrar. substring ( 1 , Strrar. Length - 7 );
Strinfo = " X " + Lbltree. Text + @" RAR/test.rar " + " " + Lbltree. Text + @" Unrar " ;
Psiinfo = New Processstartinfo ();
Psiinfo. filename = Strrar;
Psiinfo. Arguments = Strinfo;
Psiinfo. windowstyle = Processwindowstyle. hidden;
Pprocess = New Process ();
Pprocess. startinfo = Psiinfo;
Pprocess. Start ();
Response. Write ( " <Font color = Red> decompressed </font> " );
}
Catch (Exception ex)
{
Response. Write (ex. tostring ());
}