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");
}
}
}