Solved

Retreive file summary information using c#

Posted on 2004-09-21
6
2,859 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Recommendation vb6 to vb.net or others 14 202
Looking for a network enabled locker remotely controlled like Amazon locker 2 103
ejb wildfly example 2 70
Survey branching tutorial 11 38
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.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

762 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