asp.net 与解压缩

src="http://www.51aspx.com/inc/bbs_topic_view.htm" frameborder="0" width="250" scrolling="no" height="250">
///
  ///create the folders that the string defined.
  ///

  /// string
  public string Create_Folder(string folder)
  {
  string strSymbol="/";
  string temp=folder;
  string strPath=Server.MapPath(strRootDir);
  string str_a=strPath ;
  while(temp.Length>1){
    if (temp.IndexOf(strSymbol)<1)
    {
    temp=temp.Substring(1,temp.Length-1);
    }
    string childfolder=GetFirstStr(temp,strSymbol);
    temp=temp.Substring(temp.IndexOf(strSymbol));
    str_a=str_a + "/" + childfolder;
    if(!Directory.Exists(str_a)){
    Directory.CreateDirectory(str_a);
    }
  }
  return str_a;
  }
 
 
  ///
  /// upload file to the define folder by type,1--customer files ,2--compress file.
  ///

  /// string
  /// HtmlInputFile
  /// filename
  public string Up_File(string folder,HtmlInputFile fl_Name1)
  {
  string extendstr=GetLastStr(fl_Name1.PostedFile.FileName,".").ToLower();
  string strPath=Server.MapPath(strRootDir) + folder;
  //create folder
  Create_Folder(folder);
  //string strPath="";
  string filename1=GetDataRandom();
  filename1=filename1+"."+GetLastStr(fl_Name1.PostedFile.FileName,".");
  string strFullPath=strPath+filename1;
  if(File.Exists(strFullPath))
  {
    throw(new Exception());;
  }
  fl_Name1.PostedFile.SaveAs(strFullPath);
 
  return filename1;
  }
 
    ///
  ///  Extract file to the currect folder
  ///

  /// string
  /// string
  public void ExtractFile(string filename,string path1){
  try{
    Process[] myProcesses;
    myProcesses=Process.GetProcessesByName("winRAR.exe");
    foreach (Process myProcess in myProcesses){
    myProcess.CloseMainWindow();
    //myProcess.Close();
    }
  }catch{
      //go on
  }
 
  try{
    Process[] myProcesses1;
    myProcesses1=Process.GetProcessesByName("rundll32.exe");
    foreach (Process myProcess in myProcesses1){
    myProcess.CloseMainWindow();
    //myProcess.Close();
    }
  }catch{
      //go on
  } 
            Process selProcess = null;
            ProcessStartInfo psi = new ProcessStartInfo() ;
   
            psi.FileName = "winRAR.exe" ;
  string arguments="x  -o+ -r -ac " + filename ;
            psi.Arguments = arguments ;
            psi.CreateNoWindow = true ; //Optional
            psi.WorkingDirectory = path1 ; //Execute in the local Vroot
            //Response.Write(Server.MapPath("."));
            //Start the process
            System.Diagnostics.Process.Start(psi);
      selProcess=System.Diagnostics.Process.GetCurrentProcess();
  selProcess.Close();
  //System.IO.File.Delete(path1 + "/" + filename);
  }


应用到创建文件夹和如何压缩文件,asp.net如何创建进程 不能算一片好文章但代码非常实用 

你可能感兴趣的:(asp.net 与解压缩)