Solved

Retreive file summary information using c#

Posted on 2004-09-21
6
2,861 Views
Last Modified: 2008-01-09
I am looking for a way to retrieve summary information from a file. Such as "Title", "Subject", "Author", "Comments".
Moreover, the values you give to the attributes in the properties of the file when you right-click on it.

I am looking mainly for txt files and office documents.

I've got the following information without a problem using System.IO:

DirectoryInfo dirInfo = new DirectoryInfo(strRootPath);
DirectoryInfo[] dirs = dirInfo.GetDirectories();
int iNumOfFiles = dirInfo.GetFiles().Length;
FileInfo[] fInfo = new FileInfo[ iNumOfFiles ];
fInfo = dirInfo.GetFiles();
foreach(FileInfo fi in fInfo)
{
    lblInfo.Text +=fi.Name+" "+fi.Size.... //which I am able to get some information about each file. But not exactly what i need!
}

Thanks for the help
Joao Clementi


                                    
My environment is: Visual Studio .Net 2003 (ASP.NET and C#)
0
Comment
Question by:joaoclementi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 19

Accepted Solution

by:
Desp earned 250 total points
ID: 12111762
0
 

Author Comment

by:joaoclementi
ID: 12119274
Thank you... I followed the instructions and was able to refence the DSFile component but I have the following problem in the line I am suppouse to declare the PropertyReaderClass.

####################################################################################
Access is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

####################################################################################

ERROR--->PropertyReaderClass myProp = new PropertyReaderClass();
DocumentProperties dpFile = myProp.GetDocumentProperties(@"c:\test\license.txt");

I have tried modifying the permission of the files but nothing is working. I know it must be something really trivial.

Thaks for the help
0
 
LVL 19

Expert Comment

by:Desp
ID: 12119915
.txt (text file) ??? they dont have any such properties
i suppose its MS office document!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:joaoclementi
ID: 12122162
Actually the example used a .txt file but the error happens in the line before.

I tried changing to a .doc but the point is that it's not even getting to that line of code when i debug.

ERROR--->PropertyReaderClass myProp = new PropertyReaderClass();


0
 
LVL 19

Expert Comment

by:Desp
ID: 12122339
give proper privileges to the ASP.Net on the folder where the files are located
0
 

Author Comment

by:joaoclementi
ID: 12136650
Thanks Desp, I got it working

Actually the problem occured in the component registration and not in setting the priviledges to the folder. I removed the previous registration of the dll from a folder that was located in "My Documents" and placed under the C:/DsoFile and its now working.

Another problem that I am facing is when I get the properties for the first time, everything is fine and I am able to display the information on the web page, but as soon as the page reloads the line:
DocumentProperties dpFile = myProp.GetDocumentProperties(@"c:\test\license.doc") fails giving the folowing error log:
************************************************************************
Source            : Dsofile.dll
Method            : GetDocumentProperties
Date            : 2:59:35 PM
Time            : 9/23/2004
Error            : The file you have selected has no document properties.
Stack Trace      : at DSOleFile.PropertyReaderClass.GetDocumentProperties(String sFileName)
   at WFFM.list.SetFiles()
************************************************************************
then even when I close the app and try to move or delete those files manually a warning message comes up saying that another program is using that file, but I closed all browsers and visual studio. So something is not releasing the resource, do you have any idea what that might be?

Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to Have Macro Files Automatically "Edit" 5 78
C qsort compare function issue 6 70
Assignment from incompatible pointer type? 2 78
Java import explained 4 49
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question