tianma3798

1.获取方式如下

Environment.SpecialFolder中定义了许多常用的目录
//获取当前系统磁盘符方法1,返回:C:
string path = Environment.GetEnvironmentVariable("systemdrive");
//获取当前系统磁盘符方法2,返回:C:
string path = Environment.ExpandEnvironmentVariables("%systemdrive%");
Console.WriteLine(path);
//获取当前系统目录
Console.WriteLine("GetFolderPath: {0}",Environment.GetFolderPath(Environment.SpecialFolder.System));
//获取当前系统桌面
Console.WriteLine("GetFolderPath: {0}", Environment.GetFolderPath(Environment.SpecialFolder.System));

 

分类:

技术点:

相关文章:

  • 2021-09-30
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
  • 2021-09-30
  • 2021-09-30
猜你喜欢
  • 2022-03-04
  • 2021-10-22
  • 2021-05-20
  • 2022-02-14
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
相关资源
相似解决方案