SHGetFileInfo is a necessary function. You need to pass the FILE_ATTRIBUTE_DIRECTORY flag as a parameter to the dwFileAttributes parameter.
Based on the same answer you linked . I changed the code to work for directories.
public static string GetFileFolderTypeDescription(string fileNameOrExtension) { SHFILEINFO shfi; if (IntPtr.Zero != SHGetFileInfo( fileNameOrExtension, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY, out shfi, (uint)Marshal.SizeOf(typeof(SHFILEINFO)), SHGFI_USEFILEATTRIBUTES | SHGFI_TYPENAME)) { return shfi.szTypeName; } return null; }
Sriram sakthivel
source share