473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 1438
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alexander Kervero | last post by:
Hi ,today i was reading diveinto python book,in chapter 5 it has a very generic module to get file information,html,mp3s ,etc. The code of the example is here :...
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
7
by: John R. | last post by:
How do you set the following file attributes: Compressed Encrypted Normal ReparsePoint SparsePoint You CAN'T set these using FileInfo.Attributes or File.SetAttributes. It doesn't work for...
13
by: Alexandra | last post by:
Hi, I have a hidden system file that I need to read. I am logged in as an administrator. I can not change the file attributes using the windows explorer.
6
by: Samuel M. Smith | last post by:
I have been playing around with a subclass of dict wrt a recipe for setting dict items using attribute syntax. The dict class has some read only attributes that generate an exception if I try to...
11
by: Nathan Sokalski | last post by:
I add several JavaScript events (onchange, onkeypress, etc.) to Controls using the Add method of the Attributes collection. However, if the JavaScript code contains certain characters, such as & or...
6
by: Jakub.Bednarczuk | last post by:
Hallo everybody I have the problem with getting attributes values and also attributes names. I am reading an xml file with DOM. Lets see an example: file I read <root> <Def></Def>...
12
by: blackirish | last post by:
Hi all, I am trying to merge 2 XML files that first of all i need to compare nodes of both files according to 2 attributes in the nodes. If those 3 attributes are equal, i need to replace the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.