diff --git a/PInvoke/Shell32/KnownFolderIdExt.cs b/PInvoke/Shell32/KnownFolderIdExt.cs index 6cdd0a4f..1dd67b38 100644 --- a/PInvoke/Shell32/KnownFolderIdExt.cs +++ b/PInvoke/Shell32/KnownFolderIdExt.cs @@ -24,6 +24,11 @@ namespace Vanara.PInvoke return path; } + /// Retrieves the IShellItem associated with a . + /// The known folder. + /// The instance. + public static IKnownFolder GetIKnownFolder(this KNOWNFOLDERID id) => new IKnownFolderManager().GetFolder(id.Guid()); + /// Retrieves the IShellItem associated with a . /// The known folder. /// The instance. @@ -61,7 +66,23 @@ namespace Vanara.PInvoke /// Retrieves the name associated with a . /// The known folder. /// The name. - public static string Name(this KNOWNFOLDERID id) => id.GetRegistryProperty("Name"); + public static string Name(this KNOWNFOLDERID id) => id.GetIKnownFolder().Name(); + + /// Retrieves the name associated with a . + /// The known folder. + /// The name. + public static string Name(this IKnownFolder kf) + { + var fd = kf.GetFolderDefinition(); + try + { + return fd.pszName.ToString(); + } + finally + { + FreeKnownFolderDefinitionFields(fd); + } + } /// Retrieves the PIDL associated with a . /// The known folder.