If we are using a managed server it is usually necessary to implement file upload download (instead of FTP function for remote file management) has improved the efficiency of file processing the following program code enables automatic decompression of files
The
///<summary>
///uncompress the specified RAR file.
///</summary>
///<param name= "rarfiletodecompress" >rar file (absolute path). </param>
///<param name= "Directorytosave" > Unzip the saved directory. </param>
///<param name= "Deleterarfile" to delete the RAR file after decompression. </param>
public void Decompressrar (string rarfiletodecompress, String directorytosave, bool deleterarfile)
{
String winrarexe = Server.MapPath (@). /enterprisecustom/winrar.exe ")//need to place the Winara.exe executable file under the specified path to locate the file
if (new FileInfo (Winrarexe) under the installation directory. Exists)
{
Directorytosave = Checkdirectoryname (directorytosave);
Try
{
Process P = new process ();
The program name that needs to be started
p.StartInfo.FileName = Winrarexe;
Parameter
String arguments = @ "X-inul-y-o+";
Arguments + = "" + rarfiletodecompress + "" + directorytosave;
P.startinfo.arguments = Arguments;
P.start ();/Start
while (!p.hasexited)
{
}
p.WaitForExit ();
}
catch (Exception ee)
{
throw new Exception ("An error occurred during decompression of the uploaded compressed file!") <BR> Please contact the administrator to check if you have write permission to the corresponding directory! ");
}
if (deleterarfile)
{
File.delete (rarfiletodecompress);
}
Else
{
throw new Exception ("The required Winrar.exe file is missing on the system server, please contact administrator!");
}
}