By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,899 Members | 1,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,899 IT Pros & Developers. It's quick & easy.

Getting file properties programatically

P: n/a
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
Nov 15 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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
"Ram [MSFT]" <ra****@online.microsoft.com> wrote in message news:OT**************@TK2MSFTNGP12.phx.gbl...
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
Nov 15 '05 #2

P: n/a
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/de...WordObject.asp
--
Mike Mayer - Visual C# MVP
http://www.mag37.com/csharp/
mi**@mag37.com
"Ram [MSFT]" <ra****@online.microsoft.com> wrote in message
news:OT**************@TK2MSFTNGP12.phx.gbl...
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
Nov 15 '05 #3

P: n/a
> 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/Pr...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: ch***@kognition.co.nz
Nov 15 '05 #4

P: n/a

Have a look at
http://support.microsoft.com/?kbid=224351
http://www.microsoft.com/technet/tre...er/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(txtTitl e.Text);
propTemp.Id = 40091; // Title
propTemp.Len = Value.Length;
propTemp.Value = Value;
imgImage.SetPropertyItem(propTemp);

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

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

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

Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtSubj ect.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)
"Ram [MSFT]" <ra****@online.microsoft.com> wrote in message news:OT**************@TK2MSFTNGP12.phx.gbl...
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
Nov 15 '05 #5

P: n/a
"Ram [MSFT]" <ra****@online.microsoft.com> wrote in message
news:OT**************@TK2MSFTNGP12.phx.gbl...
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=e...%40cppssbbsa04

HTH.
Nov 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.