Compressed file C # program code

Source: Internet
Author: User

/// <Summary>
/// Compressed file
/// </Summary>
/// <Param name = "patch"> compressed file or its directory </param>
/// <Param name = "rarpatch"> directory for storing compressed files </param>
/// <Param name = "rarname"> name of the compressed file </param>
Private void rarsave (string patch, string rarpatch, string rarname)
{
String the_rar;
Microsoft. win32.registrykey the_reg;
Object the_obj;
String the_info;
System. Diagnostics. processstartinfo the_startinfo;
System. Diagnostics. Process the_process;

Try
{
String strcompressway = string. empty;
If (this. iscompress = "1" & this. compressway = "WinRAR ")
Strcompressway = @ "WinRAR ";
Else if (this. iscompress = "1" & this. compressway = "WinZip ")
Strcompressway = @ "WinZip ";
Else
Return;

The_reg = Microsoft. win32.registry. classesroot. opensubkey (strcompressway );
If (the_reg = NULL)
{
MessageBox. Show ("Please install WinRAR or WinZip software! ");
Return;
}

The_obj = the_reg.getvalue ("");
The_rar = the_obj.tostring ();
The_reg.close ();
// System. Io. Directory. createdirectory (patch );
The_rar = the_rar.substring (0, the_rar.length-5 );
// Command Parameters
The_info = "A" + rarname + "" + patch + "-R ";

The_startinfo = new system. Diagnostics. processstartinfo ();
The_startinfo.filename = the_rar; //; "WinRAR"
The_startinfo.arguments = the_info;
The_startinfo.windowstyle = system. Diagnostics. processwindowstyle. hidden;
// Directory for storing packaged files
The_startinfo.workingdirectory = rarpatch;
The_process = new system. Diagnostics. Process ();
The_process.startinfo = the_startinfo;
The_process.start ();
The_process.waitforexit ();
The_process.close ();
}
Catch (exception ex)
{
Throw ex;
}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.