修改檔案及其目錄的名稱
阿新 • • 發佈:2019-01-05
實現效果:
知識運用:
File類的Move方法 //將指定檔案移動到新位置
public static void Move(string sourceFileName,string destFileName)
Directory類的Move方法 //將檔案或目錄及其內容移動到新位置
public static void Move(string sourceDirName,string destDirName)
實現程式碼:
private void button2_Click(object sender, EventArgs e) { if (textBox2.Text != string.Empty) { try { Directory.Move(textBox1.Text, select + textBox2.Text); //進行命名 Refrech(listBox1,select); //執行重新整理 } catch (Exception ex) //捕獲衝突 { MessageBox.Show(ex.Message); } } }