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));
【C#】获取当前系统桌面、我的照片、我的文档等路径
获取当前系统桌面.我的照片.我的文档等路径 using System; using System.Collections.Generic; using System.ComponentModel; …
python,winreg,获取当前系统的桌面绝对路径
import winreg import os def main(): new_path = os.path.join(desktop_path(), ‘aaa.xlsx’) # 结果为:C:\\Us …