예제 #1
0
 private void btn_Local_Rename_Click(object sender, RoutedEventArgs e)
 {
     if (lst_Local.SelectedItem != null)
     {
         try
         {
             Name_Dialog rename = new Name_Dialog();
             rename.txt_name.Text = LOCAL_PICKED;
             rename.ShowDialog();
             if (rename.will_name)
             {
                 Computer MyComputer = new Computer();
                 if (Directory.Exists(UPLOAD_FROM))
                 {
                     MyComputer.FileSystem.RenameDirectory(UPLOAD_FROM, rename.txt_name.Text);
                 }
                 else if (File.Exists(UPLOAD_FROM))
                 {
                     MyComputer.FileSystem.RenameFile(UPLOAD_FROM, rename.txt_name.Text);
                 }
                 else
                 {
                     throw (new Exception("文件/文件夹不存在!"));
                 }
             }
         }
         catch (Exception ex)
         {
             txt_File_Info.Text += "\n" + ex.ToString();
         }
     }
 }
예제 #2
0
 private void btn_Local_Newfolder_Click(object sender, RoutedEventArgs e)
 {
     if (Directory.Exists(LOCAL_PATH))
     {
         try
         {
             Name_Dialog name = new Name_Dialog();
             name.txt_name.Text = "";
             name.ShowDialog();
             if (name.will_name)
             {
                 String dic_name = LOCAL_PATH + "\\" + name.txt_name.Text;
                 if (!Directory.Exists(dic_name))//如果不存在就创建 dir 文件夹
                 {
                     Directory.CreateDirectory(dic_name);
                 }
             }
         }
         catch (Exception ex)
         {
             txt_File_Info.Text += "\n" + ex.ToString();
         }
     }
 }