Esempio n. 1
0
 /// <summary>
 /// 粘贴
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnPaste_Click(object sender, EventArgs e)
 {
     if (ViewState["clipboard"] != null)
     {
         if (ViewState["action"].ToString() == "cut")
         {
             List <string> items = (List <string>)ViewState["clipboard"];
             foreach (string s in items)
             {
                 if (Directory.Exists(s))
                 {
                     if (!Directory.Exists(lblCurrentPath.Text + s.Substring(s.LastIndexOf("\\"))))
                     {
                         Directory.Move(s, lblCurrentPath.Text + s.Substring(s.LastIndexOf("\\")));
                     }
                     else
                     {
                         ShowErr("当文件夹已存在时,无法创建该文件夹。");
                     }
                 }
                 else
                 {
                     if (!File.Exists(lblCurrentPath.Text + "\\" + Path.GetFileName(s)))
                     {
                         File.Move(s, lblCurrentPath.Text + "\\" + Path.GetFileName(s));
                     }
                     else
                     {
                         ShowErr("当文件已存在时,无法创建该文件。");
                     }
                 }
             }
         }
         else
         {
             List <string> items = (List <string>)ViewState["clipboard"];
             foreach (string s in items)
             {
                 if (Directory.Exists(s))
                 {
                     DirectoryInfo di = new DirectoryInfo(s);
                     FileSystemManager.CopyFolder(s, lblCurrentPath.Text + "\\" + di.Name);
                 }
                 else
                 {
                     File.Copy(s, lblCurrentPath.Text + "\\复件 " + Path.GetFileName(s), true);
                 }
             }
         }
     }
     ViewState["clipboard"] = null;
     ViewState["action"]    = null;
     BindGrid(lblCurrentPath.Text);
 }