/// <summary>
///create the folders that the string defined.
/// </summary>
/// <param name="folder">string</param>
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;
}
/// <summary>
/// upload file to the define folder by type,1--customer files ,2--compress file.
/// </summary>
/// <param name="folder">string</param>
/// <param name="fl_name1">HtmlInputFile</param>
/// <returns>filename</returns>
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;
}
/// <summary>
/// Extract file to the currect folder
/// </summary>
/// <param name="filename">string</param>
/// <param name="path1">string</param>
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);
}