C#返回系统特殊路径
发布日期:2021-06-30 19:10:47
浏览次数:3
分类:技术文章
本文共 1376 字,大约阅读时间需要 4 分钟。
using System; using Microsoft.Win32; namespace SystemPathsApp { /// <summary> /// Summary description for SystemPaths. /// </summary> public class SystemPaths { public SystemPaths() { // // TODO: Add constructor logic here // folders = OpenRegistryPath(Registry.CurrentUser,@"/Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders"); } private RegistryKey folders; 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; } /// <summary> /// </summary> /// <param name="path"> /// Desktop 桌面目录 /// Fonts 字体目录 /// NetHood 网上邻居 /// Personal 我的文档目录 /// Programs 开始菜单程序目录 /// Recent 存放用户最近访问文件快捷方式的目录 /// SendTo 发送到目录 /// StartMenu 开始菜单目录 /// Startup 开始菜单启动项目录 /// Favorites 收藏夹目录 /// History 网页历史目录 /// Cookies cookies目录 /// Cache 缓存目录 /// AppData 应用程序数据目录 /// PrintHood 打印目录 /// </param> /// <returns></returns> public string Customize(string path) { return folders.GetValue(path).ToString(); } public string Desktop() { return Customize("Desktop"); } public string Cookies() { return Customize("Cookies"); } public string MyDocuments() { return Customize("Personal"); } public string History() { return Customize("History"); } public string Favorites() { return Customize("Favorites"); } } }转载地址:https://linuxstyle.blog.csdn.net/article/details/1539776 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月20日 07时49分51秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
ACM 2013 长沙区域赛 Collision (几何)
2019-04-30
CodeForces - 1064A Make a triangle! (简单模拟)
2019-04-30
51Nod - 1183 编辑距离 (dp)
2019-04-30
ACM 2014 鞍山区域赛 E - Hatsune Miku (dp)
2019-04-30
反向传播&梯度下降 的直观理解程序(numpy)
2019-04-30
ACM 2017 南宁区域赛 Rake it in(对抗搜索)
2019-04-30
CodeForces - 931B World Cup (思维 模拟)
2019-04-30
CodeForces - 996D Suit and Tie (暴力)
2019-04-30
ACM 2017 香港区域赛 E - Base Station Sites(二分)
2019-04-30
ACM 2018 青岛区域赛 J-Books (模拟)
2019-04-30
ACM 2016 沈阳区域赛 E - Counting Cliques (dfs)
2019-04-30
ACM 2017 北京区域赛 J-Pangu and Stones(区间dp)
2019-04-30
HDU - 5643 King's Game (约瑟夫环变式)
2019-04-30
UVA - 1452 Jump (约瑟夫环变式)
2019-04-30
POJ - 3517 And Then There Was One (约瑟夫环变式)
2019-04-30
HDU - 2068 RPG的错排 (错排+组合数)
2019-04-30
CodeForces 591C Median Smoothing(思维 模拟)
2019-04-30
升级yosemite后java出错的解决
2019-04-30