C#获取用户桌面等特殊系统路径
2015-01-15 08:38
393 查看
using Microsoft.Win32; namespace JPGCompact { public partial classMainForm : Form { private void Test() { RegistryKey folders; folders =OpenRegistryPath(Registry.CurrentUser,@"/software/microsoft/windows/currentversion/explorer/shellfolders"); //Windows用户桌面路径 stringdesktopPath = folders.GetValue("Desktop").ToString(); //Windows用户字体目录路径 stringfontsPath = folders.GetValue("Fonts").ToString(); //Windows用户网络邻居路径 stringnethoodPath = folders.GetValue("Nethood").ToString(); //Windows用户我的文档路径 stringpersonalPath = folders.GetValue("Personal").ToString(); //Windows用户开始菜单程序路径 stringprogramsPath = folders.GetValue("Programs").ToString(); //Windows用户存放用户最近访问文档快捷方式的目录路径 stringrecentPath = folders.GetValue("Recent").ToString(); //Windows用户发送到目录路径 stringsendtoPath = folders.GetValue("Sendto").ToString(); //Windows用户开始菜单目录路径 stringstartmenuPath = folders.GetValue("Startmenu").ToString(); //Windows用户开始菜单启动项目录路径 stringstartupPath = folders.GetValue("Startup").ToString(); //Windows用户收藏夹目录路径 stringfavoritesPath = folders.GetValue("Favorites").ToString(); //Windows用户网页历史目录路径 stringhistoryPath = folders.GetValue("History").ToString(); //Windows用户Cookies目录路径 stringcookiesPath = folders.GetValue("Cookies").ToString(); //Windows用户Cache目录路径 stringcachePath = folders.GetValue("Cache").ToString(); //Windows用户应用程式数据目录路径 stringappdataPath = folders.GetValue("Appdata").ToString(); //Windows用户打印目录路径 stringprinthoodPath = folders.GetValue("Printhood").ToString(); } private RegistryKey OpenRegistryPath(RegistryKeyroot, string s) { s =s.Remove(0, 1) + @"/"; while(s.IndexOf(@"/") != -1) { root =root.OpenSubKey(s.Substring(0, s.IndexOf(@"/"))); s = s.Remove(0,s.IndexOf(@"/") + 1); } returnroot; } } } 获取系统特殊文件夹路径(收藏夹,桌面) 1. 收藏夹路径 System.Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites) 2. 桌面路径 System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) 更多请见枚举类 System.Environment.SpecialFolder
相关文章推荐
- C#获取用户桌面等特殊系统路径
- C#获取用户桌面等特殊系统路径
- C#获取用户桌面等特殊系统路径
- 【转】C#获取用户桌面等特殊系统路径
- C#获取用户桌面等特殊系统路径
- C#获取用户桌面等特殊系统路径
- C#获取用户桌面等特殊系统路径
- C#获取DLL、程序路径,C#获取桌面、收藏夹等特殊系统路径
- C#获取DLL、程序路径,C#获取桌面、收藏夹等特殊系统路径
- 获得系统特殊路径函数SHGetSpecialFolderLocation()获取当前用户桌面
- C#获取DLL、程序路径,C#获取桌面、收藏夹等特殊系统路径
- VC 获取系统特殊文件夹的路径如:系统目录,桌面等
- C#获取特殊系统路径
- 获取当前系统桌面路径(C# 代码)
- VC 获取系统特殊文件夹的路径如:系统目录,桌面等
- C#:获取Windows系统特殊文件夹的路径
- C#获取“所有用户”的路径, 我的桌面,我的文档,我的音乐,我的图片等等目录
- VC 获取系统特殊文件夹的路径如:系统目录,桌面等
- C#获取“所有用户桌面”的路径
- VC++ 获取系统特殊文件夹的路径 桌面等