Solved

Retreive file summary information using c#

Posted on 2004-09-21
6
2,862 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Part One of the two-part Q&A series with MalwareTech.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Six Sigma Control Plans

617 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