我是靠谱客的博主 典雅小霸王,最近开发中收集的这篇文章主要介绍使用C#返回系统特殊路径 (转),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

使用C#返回系统特殊路径 (转)[@more@]

using System;
using microsoft.win32;

namespace SystemPathsApp
{
 ///
 /// Summary description for SystemPaths.
 ///
 public class SystemPaths
 {
 public SystemPaths()
 {
 //
 // TODO: Add constructor logic here
 //
 folders = OpenRegistryPath(Registry.CurrentUser,@"SoftwareMicrosoftwindowsCurrentVersionExplorershell 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;
 }

 ///
 ///
 ///
 /// Desktop 桌面目录
 /// Fonts 字体目录
 ///.NETHood 网上邻居
 /// Personal 我的文档目录
 /// Programs 开始菜单程序目录
 /// Recent 存放用户最近访问文件快捷方式的目录
 /// SendTo 发送到目录
 /// StartMenu 开始菜单目录
 /// Startup 开始菜单启动项目录
 /// Favorites 收藏夹目录
 /// History 网页历史目录
 /// Cookies cookies目录
 /// Cache 缓存目录
 /// AppData 应用程序数据目录
 /// PrintHood 打印目录
 ///
 ///
 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");
 }

 }
}


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752019/viewspace-957813/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752019/viewspace-957813/

最后

以上就是典雅小霸王为你收集整理的使用C#返回系统特殊路径 (转)的全部内容,希望文章能够帮你解决使用C#返回系统特殊路径 (转)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部