2022年12月21日 星期三

[C#] 新增資料夾

using System.IO;
string folderPath = @"C:\\Users\\user\\OneDrive\\桌面\\新檔案";
// 如果資料夾不存在,則新增資料夾
if (!Directory.Exists(folderPath))
   {
       Directory.CreateDirectory(folderPath);
       Console.WriteLine("資料夾已新增");
   }
   else
   {
       Console.WriteLine("資料夾已存在");
   }
}

沒有留言:

張貼留言