tags:

views:

64

answers:

4

When you right-click on a file in Windows and select "Properties" from the menu, it opens the Properties window. On that window for most files types there's a "Summary" tab that contains a variety of information.

Is there a managed/.NET way to retrieve that information? I had assumed incorrectly that this would be a trivial thing to do and that it would all be part of some dictionary object on the System.IO.FileInfo object and you could just feed it a string of the tag you wanted and it would return some value. I was way wrong.

In my searches all I've been finding are shell commands, mentions of api calls or installing com objects. Those are fallback solutions (and ones I would rather avoid). What I really want to know is if I'm overlooking a .NET way of accessing that information?

A: 

I had assumed incorrectly that this would be a trivial thing to do and that it would all be part of some dictionary object on the System.IO.FileInfo object and you could just feed it a string of the tag you wanted and it would return some value

System.IO.FileInfo.Attributes
Jay
That is not what he is looking for.
Jason
Oh, THAT. I think that's the OSs ability to read into known filetypes -- I don't think those are part of the filesystem (though they may be cached somewhere).
Jay
A: 

Have you tried System.Diagnostics.FileVersionInfo?

var fvi = FileVersionInfo.GetVersionInfo("c:\temp.txt");

Patrick.

Patrick
A: 

There's the DSOfile.dll that lets you edit these for Office documents. Unfortunately, I don't think these properties are universal for files - they won't always be available.

Just re-read your paragraph saying that COM objects are fallback solutions - however, this is the solution provided on the MS website, so I don't think you're going to do much better.

Damien_The_Unbeliever
A: 

What you want is called Structured Storage and this information is accessible via StgOpenStorageEx which is in Ole32.dll. Looking at the pinvoke.net page for this method, it appears that some of the functionality can be extracted using System.IO.Packaging.StorageInfo but that it requires some work to do this and it looks like you still have to use P/Invoke.

Jason
Yeah, you're confirming what I had discovered. sigh, I was really hoping there was another way. Thanks for the answer even if it's one I was hoping not to hear!
George Clingerman