private static string GetPath(FolderEnum folderEnum, FolderFlags flags, bool defaultUser) { var result = SHGetKnownFolderPath(new Guid(_folderGuids[(int)folderEnum]), (uint)flags, new IntPtr(defaultUser ? -1 : 0), out var outPath); if (result >= 0) { string path = Marshal.PtrToStringUni(outPath) ?? throw new NullReferenceException("Marshal.PtrToStringUni(outPath)"); Marshal.FreeCoTaskMem(outPath); return(path); } throw new ExternalException("Unable to retrieve the known folder path. It may not " + "be available on this system.", result); }
public static string GetPath(FolderEnum folderEnum, bool defaultUser) { return(GetPath(folderEnum, FolderFlags.DontVerify, defaultUser)); }
public static string GetPath(FolderEnum folderEnum) { return(GetPath(folderEnum, false)); }