Getting file properties programatically

R

Ram [MSFT]

Hi All,

I'm trying to programatically (using c#) read the file properties (Title, Summary, Author, Comments etc.... The stuff that shows up on the Summary tab when you see the properties of a file).

FileInfo and FileSystemInfo classes expose only the standard properties (create time, mod time etc..).

Any pointers would be greatly appreciated.

Thanks,
Ram Thiru
 
B

Brian W

Jeez! What's the world coming to? A Microsoft guy asking for help here ?!

A similar question was asked a week or so ago.

As I understand it, most of these custom properties are stored as part of the file itself and are retrieved by the application that created the file.

For example:
Title, Summary, Author & Comments that MS Word would save as part of a Word document. When the OS displays these properties they are somehow provided by Word by the OS

As I said that is how I understand it.


HTH
Brian W
Hi All,

I'm trying to programatically (using c#) read the file properties (Title, Summary, Author, Comments etc.... The stuff that shows up on the Summary tab when you see the properties of a file).

FileInfo and FileSystemInfo classes expose only the standard properties (create time, mod time etc..).

Any pointers would be greatly appreciated.

Thanks,
Ram Thiru
 
M

Michael Mayer [C# MVP]

Wait for Longhorn and use the new WinFS relational database and some new
..Net API to get to metadata for the file ;-)

More seriously, based on Brian's advice, using Word automation can probably
get to it for a Word document. I'm not an expert on Word automation (haven't
done it since VB6).

This is a somewhat an overview doc, not sure where the real docs are for the
Word object model.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_vsto2003_ta/html/WordObject.asp


--
Mike Mayer - Visual C# MVP
http://www.mag37.com/csharp/
(e-mail address removed)


Hi All,

I'm trying to programatically (using c#) read the file properties (Title,
Summary, Author, Comments etc.... The stuff that shows up on the Summary tab
when you see the properties of a file).

FileInfo and FileSystemInfo classes expose only the standard properties
(create time, mod time etc..).

Any pointers would be greatly appreciated.

Thanks,
Ram Thiru
 
C

Chris J.T. Auld [MVP]

More seriously, based on Brian's advice, using Word automation can
probably
get to it for a Word document. I'm not an expert on Word automation (haven't
done it since VB6).

You may be able to work something out by having a play with Index Server.
Index Server will index the extended properties of those files and then when
you query the index you can read the properties. May allow you to kill some
more birds with ya stone? Index Server can be an ass to setup though.
Take a look at
http://idunno.org/dotNet/indexserver.aspx
and
http://www.microsoft.com/ntserver/ProductInfo/faqs/indexfaq.asp#searchprop

Cheers
Chris

****Please Reply To The Newsgroup So All Can Benefit From Discussion****
-------------------------------------------
Kognition Consulting Limited - Thought Meets Technology
Chris J.T. Auld - Managing Director
Microsoft MVP (Windows Mobile Devices)
Phone: +64 3 453 0064
Mobile: +64 21 500 239
Email: (e-mail address removed)
 
?

=?iso-8859-1?Q?=C9ric_Moreau?=

Have a look at
http://support.microsoft.com/?kbid=224351
http://www.microsoft.com/technet/tr...=/technet/scriptcenter/filefolder/ScrFF64.asp

I also have this code which I never tried!

private void btnSave_Click(object sender, System.EventArgs e)
{
// Set the temporary property to the first of properties that the JPG already has
System.Drawing.Imaging.PropertyItem propTemp = propAllProperties[0];

byte[] Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtTitle.Text);
propTemp.Id = 40091; // Title
propTemp.Len = Value.Length;
propTemp.Value = Value;
imgImage.SetPropertyItem(propTemp);

Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtComments.Text);
propTemp.Id = 40092; // Comments
propTemp.Len = Value.Length;
propTemp.Value = Value;
imgImage.SetPropertyItem(propTemp);

Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtAuthor.Text);
propTemp.Id = 40093; // Author
propTemp.Len = Value.Length;
propTemp.Value = Value;
imgImage.SetPropertyItem(propTemp);

Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtKeywords.Text);
propTemp.Id = 40094; // Keywords
propTemp.Len = Value.Length;
propTemp.Value = Value;
imgImage.SetPropertyItem(propTemp);

Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtSubject.Text);
propTemp.Id = 40095; // Subject
propTemp.Len = Value.Length;
propTemp.Value = Value;
imgImage.SetPropertyItem(propTemp);

try
{
if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
imgImage.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
catch(Exception ee)
{
}
}
}
}

--

HTH

Éric Moreau, MCSD
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)
Hi All,

I'm trying to programatically (using c#) read the file properties (Title, Summary, Author, Comments etc.... The stuff that shows up on the Summary tab when you see the properties of a file).

FileInfo and FileSystemInfo classes expose only the standard properties (create time, mod time etc..).

Any pointers would be greatly appreciated.

Thanks,
Ram Thiru
 
M

Michael Sparks

Ram said:
Hi All,
I'm trying to programatically (using c#) read the file properties (Title,
Summary, Author, Comments etc.... The stuff that shows up on the Summary tab
when you see the properties of a file).
FileInfo and FileSystemInfo classes expose only the standard properties (create time, mod time etc..).
Any pointers would be greatly appreciated.

See the following newsgroup post from 2/28/2000. The Summary tab is a
proprietary shell extension, it gets part of its info from direct knowledge
of some file types, and other info from plugins, but the plugin COM
interfaces were never published. Looks like there was some interest in
reverse-engineering them over the years, but it doesn't appear that anyone
ever did.

http://groups.google.com/groups?hl=...F-8&safe=off&selm=#860OFgg$GA.250@cppssbbsa04

HTH.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top