471,627 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Attributes of a file

Is there a way to add Comments (right click on a file, in the summary tab
this information will be present) to a file in C#. I searched through
FileInfo class, but I could not find any properties or methods to add
comments.
Dec 28 '05 #1
2 1381
Rohith,
Is there a way to add Comments (right click on a file, in the summary tab
this information will be present) to a file in C#.


Yes there is, but I'm afraid the .NET Framework doesn't support this
directly. And, unfortunately the process is somewhat more difficult than you
might think at first.

Before we start, you need to understand something about so-called NTFS
Alternative Data Streams (ADSs). These streams allow you to associate
"hidden" data with any file, and this is what Windows Explorer does when you
associate summary information with the file, i.e. go to file properties
dialog box and its Summary tab on Windows 2000/XP/2003. If all this sounds
very new to you, I suggest reading for example this Dino Esposito's
introduction:

http://msdn.microsoft.com/library/de...html/ntfs5.asp

Now, these alternate streams are somewhat a double-edged sword as they can
be used to store both useful and not-so-useful data. See for instance here:

http://www.relsoft.net/datastreams.html

Setting the potential security issue aside, you need to be able to read and
write a special stream to your file to be able to associate summary
information with it. To do it, you would need to use some Windows API
functions. I couldn't find C# examples with quick surfing, but here's a
Delphi one:

http://www.delphipages.com/news/detaildocs.cfm?ID=104

Here's also an interesting Windows Shell Extension from The Code Project:

http://www.codeproject.com/csharp/Cs...torArticle.asp

And, yet another article that you might find useful:

http://msdn.microsoft.com/msdnmag/issues/0300/w2kui/

Hope this gets you started!

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
ja***@removethis.dystopia.fi
http://www.saunalahti.fi/janij/
Dec 28 '05 #2
Hi,

It's not supported in .net it's a feature of NTFS , you can have more than
one stream of data, usually the first (default) is the file itself, you can
use others to store info, I tried once to use a dll from MS:
http://support.microsoft.com/?id=224351 as I needed it exclusively for
office documents, try it and see if you can use it for other kind of files.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Rohith" <Ro****@discussions.microsoft.com> wrote in message
news:D1**********************************@microsof t.com...
Is there a way to add Comments (right click on a file, in the summary tab
this information will be present) to a file in C#. I searched through
FileInfo class, but I could not find any properties or methods to add
comments.

Dec 28 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Alexander Kervero | last post: by
6 posts views Thread by Samuel M. Smith | last post: by
6 posts views Thread by Jakub.Bednarczuk | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.