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 ?
-
What version of windows or what os? Where do you see a comment text? On which screen? – agent-j Jun 15 '11 at 01:58
-
1It's on the summary tab when you explore the properties of any file in XP and IIRC goes back to at least Win95 – The Evil Greebo Jun 15 '11 at 01:59
3 Answers
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

- 1
- 1

- 73,278
- 17
- 138
- 182
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.

- 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
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.

- 27,335
- 5
- 52
- 79