0

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 ?

Shyju
  • 214,206
  • 104
  • 411
  • 497

3 Answers3

2

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#)

Community
  • 1
  • 1
Samuel Neff
  • 73,278
  • 17
  • 138
  • 182
0

FileSystemObject is probably not the mechanism you want to use.

Suggest you study System.IO and look at File and FileInfo objects, as they are CLR based as opposed to FSO which, I believe, is still COM. FileInfo has an attributes collection that you can interrogate.

The Evil Greebo
  • 7,013
  • 3
  • 28
  • 55
  • `FileInfo.Attributes` tells you if the file is hidden or system or things like that. It doesn't give you the extended file info. AFAIK the only way to get that is through `FileSystemObject`. Nothing built-in to .NET BCL. http://msdn.microsoft.com/en-us/library/system.io.fileattributes.aspx – Samuel Neff Jun 15 '11 at 03:05
0

First, create a comment on a folder that is unique, like c:\mycoolfolder = I am cool. Then, use Regedit search the registry for both I am cool and c:\mycoolfolder. That may give you some hints.

agent-j
  • 27,335
  • 5
  • 52
  • 79