Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 public static string GetPath(FolderEnum folderEnum, bool defaultUser)
 {
     return(GetPath(folderEnum, FolderFlags.DontVerify, defaultUser));
 }
Ejemplo n.º 3
0
 public static string GetPath(FolderEnum folderEnum)
 {
     return(GetPath(folderEnum, false));
 }