dotnet文件操作
生活随笔
收集整理的這篇文章主要介紹了
dotnet文件操作
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/// <summary>/// 創建文件夾/// </summary>/// <param name="sender"></param>/// <param name="e"></param>protected void Button1_Click(object sender, EventArgs e){if (!Directory.Exists(path)){Directory.CreateDirectory(path);}}/// <summary>/// 刪除文件夾/// </summary>/// <param name="sender"></param>/// <param name="e"></param>protected void Button2_Click(object sender, EventArgs e){if (Directory.Exists(path)){Directory.Delete(path);}}/// <summary>/// 移動文件夾/// </summary>/// <param name="sender"></param>/// <param name="e"></param>protected void Button3_Click(object sender, EventArgs e){Directory.Move(path, newpath);}/// <summary>/// 創建文件/// </summary>/// <param name="sender"></param>/// <param name="e"></param>protected void Button4_Click(object sender, EventArgs e){if (!File.Exists(newpath + @"\myfile.txt")){File.CreateText(newpath + @"\myfile.txt");}Response.Write(String.Format("The number of files in {0} is {1}", newpath, Directory.GetFiles(newpath).Length));}/// <summary>/// 刪除文件/// </summary>/// <param name="sender"></param>/// <param name="e"></param>protected void Button5_Click(object sender, EventArgs e){if (File.Exists(newpath + @"\myfile.txt")){File.Delete(newpath + @"\myfile.txt");}}/// <summary>/// 移動文件/// </summary>/// <param name="sender"></param>/// <param name="e"></param>protected void Button6_Click(object sender, EventArgs e){File.Move(newpath + @"\myfile.txt", path + @"\file.txt");}
?
==>如有問題,請聯系我:easonjim#163.com,或者下方發表評論。<== 《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的dotnet文件操作的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android Studio 提示与技巧
- 下一篇: IIS 伪静态设置