Esempio n. 1
0
        /// <summary>
        /// Gets the current path to the specified known folder as currently configured.
        /// </summary>
        /// <param name="knownFolder">The known folder which current path will be returned.</param>
        /// <param name="flags">The known folder flags to use.</param>
        /// <param name="defaultUser">Specifies if the paths of the default user (user profile
        ///     template) will be used. This requires administrative rights.</param>
        /// <returns>The default path of the known folder, or an empty string if the path couldn't be retrieved.</returns>
        public static string GetPath(KnownFolder knownFolder, NativeMethods.KnownFolderFlags flags,
                                     bool defaultUser)
        {
            int result = NativeMethods.SHGetKnownFolderPath(new Guid(_knownFolderGuids[(int)knownFolder]),
                                                            (uint)flags, new IntPtr(defaultUser ? -1 : 0), out IntPtr outPath);

            if (result >= 0)
            {
                return(Marshal.PtrToStringUni(outPath));
            }

            return(string.Empty);
        }
Esempio n. 2
0
 /// <summary>
 /// Gets the current path to the specified known folder as currently configured.
 /// </summary>
 /// <param name="knownFolder">The known folder which current path will be returned.</param>
 /// <param name="flags">The known folder flags to use.</param>
 /// <returns>The default path of the known folder, or an empty string if the path couldn't be retrieved.</returns>
 public static string GetPath(KnownFolder knownFolder, NativeMethods.KnownFolderFlags flags)
 {
     return(GetPath(knownFolder, flags, false));
 }