C#获取特殊系统路径

using Microsoft.Win32; 
namespace JPGCompact 

    public partial class MainForm : Form 
    { 
        private void Test() 
        { 
            RegistryKey folders; 
            folders = OpenRegistryPath(Registry.CurrentUser, @"/software/microsoft/windows/currentversion/explorer/shell folders"); 
            // Windows用户桌面路径  
            string desktopPath = folders.GetValue("Desktop").ToString(); 
            // Windows用户字体目录路径  
            string fontsPath = folders.GetValue("Fonts").ToString(); 
            // Windows用户网络邻居路径  
            string nethoodPath = folders.GetValue("Nethood").ToString(); 
            // Windows用户我的文档路径  
            string personalPath = folders.GetValue("Personal").ToString(); 
            // Windows用户开始菜单程序路径  
            string programsPath = folders.GetValue("Programs").ToString(); 
            // Windows用户存放用户最近访问文档快捷方式的目录路径  
            string recentPath = folders.GetValue("Recent").ToString(); 
            // Windows用户发送到目录路径  
            string sendtoPath = folders.GetValue("Sendto").ToString(); 
            // Windows用户开始菜单目录路径  
            string startmenuPath = folders.GetValue("Startmenu").ToString(); 
            // Windows用户开始菜单启动项目录路径  
            string startupPath = folders.GetValue("Startup").ToString(); 
            // Windows用户收藏夹目录路径  
            string favoritesPath = folders.GetValue("Favorites").ToString(); 
            // Windows用户网页历史目录路径  
            string historyPath = folders.GetValue("History").ToString(); 
            // Windows用户Cookies目录路径  
            string cookiesPath = folders.GetValue("Cookies").ToString(); 
            // Windows用户Cache目录路径  
            string cachePath = folders.GetValue("Cache").ToString(); 
            // Windows用户应用程式数据目录路径  
            string appdataPath = folders.GetValue("Appdata").ToString(); 
            // Windows用户打印目录路径  
            string printhoodPath = folders.GetValue("Printhood").ToString(); 
        } 
 
        private RegistryKey OpenRegistryPath(RegistryKey root, 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); 
            } 
            return root; 
        } 
    } 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

0x12

下载和转换脚本可私信我

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值