filter by file properties

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to build a filter for a file search where the search will be able
to filter out certain files according to certain "file properties", like
Owner, Creation Date, etc.
MS does this in some Open dialogs, within the dialog, you can click on
Tools->Search->Advanced and search for files with specified file properties.

Any ideas on how this is done in C#?
 
Yes, but that doesn't show the custom "properties" that can be added when
you: right click on file (for example MS Word file), click properties, go to
the "Custom" or "Summary" tabs and enter data. Where is this data stored?
And is there an API to access this data?

Thanks.
 
Appearantly there is no managed way to do this in C#, I got this from MS:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoffdev/html/vsofficedev.asp

Excerpt:
How do I access my document properties in an Office document?

You can automate Microsoft Word, Excel or PowerPoint with Visual C++ to
retrieve and manipulate both built-in and custom document properties. For
more information and an example, see HOWTO: Use Visual C++ to Access
DocumentProperties with Automation (Q238393).

You can also retrieve document property information without Automation and
even without the need for the Office application that created the file.
Office documents are OLE compound documents that store document properties in
persistent property sets. These property sets are managed by COM/OLE and can
be retrieved using the IPropertySetStorage and IPropertyStorage interfaces.
For details, see HOWTO: Read Compound Document Properties Directly with VC++
(Q186898) and Dsofile.exe Lets You Edit Office Document Properties from
Visual Basic and Active Server Pages (Q224351).
 
Ok, here's the answer, in case someone is interested:

If you don't want to use automation (automation requires ms office product
be installed),
Do a search for dsofile.dll, ms supplies an executable that will create the
dll and a sample in a directory for you.
http://support.microsoft.com/?kbid=224351

This is a MS library for reading document properties, and using it is
extremely simple:
Add library as reference

DSOleFile.PropertyReader propReader =
new DSOleFile.PropertyReaderClass();
DSOleFile.DocumentProperties docProps=
propReader.GetDocumentProperties("C:\test.doc");

and that's it.
 
Back
Top