开发者

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

开发者 https://www.devze.com 2023-03-12 20:03 出处:网络
If i create a folder in windows and right click select properties and give some comment about it 开发者_高级运维in the comment field.

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 ?


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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消