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