C#获取当前系统磁盘符、系统目录、桌面等
时间:2016-05-17 09:50:40
收藏:0
阅读:2736
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));
评论(0)