asp.net解压文件

try
        {
           
            string path = @"C:\Documents and Settings\桌面\解 压" + myfile.PostedFile.FileName.Substring(myfile.PostedFile.FileName.LastIndexOf("\\"));
            myfile.PostedFile.SaveAs(path);
            Response.Write("文件上传成功:"+path);
            //Response.End();
            // 在此处放置用户代码以初始化页面 
            Process p = new Process();   
            p.StartInfo.UseShellExecute = false;   
            p.StartInfo.RedirectStandardInput = true;   
            p.StartInfo.RedirectStandardOutput = true;   
            p.StartInfo.RedirectStandardError = true;   
            p.StartInfo.CreateNoWindow = true; 
            p.StartInfo.FileName = "cmd.exe";   
            p.Close();   
            //解压Rar文件 
            string ServerDir=@"C:\Program Files\WinRAR";//rar路径 
            System.Diagnostics.Process Process1=new Process(); 
            Process1.StartInfo.FileName=ServerDir+"\\WinRar.exe"; //不明白这儿是WinRar.exe还是Rar.exe?
            Process1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            Directory.CreateDirectory(path + ".files"); //创建解压文件夹  
            Process1.StartInfo.Arguments=@" x -inul -y-o"+path+" "+path+".files";
            Process1.Start();//解压开始 
            while(!Process1.HasExited)       //等待解压的完成 
           {
              // Process1.WaitForExit();
           }
         }
        catch (Exception ex)
        { 
            this.lblError.Text = ex.Message+ex.StackTrace; 
        }

posted @ 2014-05-17 16:30  bin89  阅读(110)  评论(0)    收藏  举报