如何在C#中为当前用户获取桌面路径?
我唯一能找到的是VB.NET-only类SpecialDirectories
,它具有以下属性:
My.Computer.FileSystem.SpecialDirectories.Desktop
我怎么能在C#中做到这一点?
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string extension = ".log"; filePath += @"\Error Log\" + extension; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); }