public static string GetFolderPath(int folder) { StringBuilder pszPath = new StringBuilder(260); PInvoke.SHGetFolderPath(IntPtr.Zero, folder, IntPtr.Zero, 0, pszPath); return(pszPath.ToString()); }
public static bool TryGetFolderPath(int folder, out string path) { StringBuilder pszPath = new StringBuilder(260); if ((PInvoke.SHGetFolderPath(IntPtr.Zero, folder, IntPtr.Zero, 0, pszPath) == 0) && (pszPath.Length > 0)) { path = pszPath.ToString(); return(true); } path = null; return(false); }