Search code examples
c#filesystemobject

C# FileSystemObject How to get folder's comment property?


If i create a folder in windows and right click select properties and give some comment about it in the comment field. in C#, How do i get the comment for a folder ? Is there any "Comment" Property available ?


Solution

  • As far as I know there is no purely managed mechanism for retrieving the extended file information. You can use the COM object Shell.Application to retrieve it though.

        Shell32.Shell shell = new Shell32.Shell();
        Shell32.Folder folder = shell.NameSpace(@"C:\temp\testprop");
        Shell32.FolderItem item = folder.ParseName("whatever.txt);
        string comment = item.GetDetailsOf("whatever.txt", 14);
    

    http://technet.microsoft.com/en-us/library/ee176615.aspx

    http://msdn.microsoft.com/en-us/library/bb787870%28v=vs.85%29.aspx

    Read/Write 'Extended' file properties (C#)