使用C#返回系统特殊路径
来源:互联网 发布:彩虹六号优化 编辑:程序博客网 时间:2024/04/30 15:12
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");
}
}
}
- 使用C#返回系统特殊路径
- c
- c
- c
- c
- C
- c
- c
- c
- C+
- c
- C
- c
- c
- c
- C
- C
- c
- ASP错误代码说明
- ADO错误代码
- 大部分的ADO的错误码对应的含义
- 使用ASP+jmail进行邮件群发
- 使用C#实现阿拉伯数字到大写中文的转换
- 使用C#返回系统特殊路径
- 如何快速实现HTML编辑器.NET组件
- 调试工具系列--Javascript正则表达式(regular expression)调试工具(符合w3c)
- J2EE 应用程序
- 使用手机连结电脑,发送端消息的实验步骤
- 微软新任Visual C++设计师Stanley Lippman访谈
- STL之父A.Stepanov专访
- 现在和将来
- C#首席设计师Anders Hejlsberg访谈