You can get the localized display name using the SHGetFileInfo API:
public static string GetDisplayName(Environment.SpecialFolder specialFolder) { IntPtr pidl = IntPtr.Zero; try { HResult hr = SHGetFolderLocation(IntPtr.Zero, (int) specialFolder, IntPtr.Zero, 0, out pidl); if (hr.IsFailure) return null; SHFILEINFO shfi; if (0 != SHGetFileInfo( pidl, FILE_ATTRIBUTE_NORMAL, out shfi, (uint)Marshal.SizeOf(typeof(SHFILEINFO)), SHGFI_PIDL | SHGFI_DISPLAYNAME)) { return shfi.szDisplayName; } return null; } finally { if (pidl != IntPtr.Zero) ILFree(pidl); } } public static string GetDisplayName(string path) { SHFILEINFO shfi; if (0 != SHGetFileInfo( path, FILE_ATTRIBUTE_NORMAL, out shfi, (uint)Marshal.SizeOf(typeof(SHFILEINFO)), SHGFI_DISPLAYNAME)) { return shfi.szDisplayName; } return null; } private const uint FILE_ATTRIBUTE_NORMAL = 0x00000080; private const uint SHGFI_DISPLAYNAME = 0x000000200;
Thomas levesque
source share