Link to home
Start Free TrialLog in
Avatar of darbid73
darbid73Flag for Germany

asked on

How to check if can / read as many text type files as possible.

Users can point any type of file at my code and I need to know if I can read the text from it.

I can deal with Office files and PDF by looking at the file extension.

But what about the rest.

What I am hoping is that I can somehow test it against streamreader or another .NET object and see if I can read the file or not.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of darbid73

ASKER

I will be writing it in VB.net for Windows 7 boxes.

Ok the list was what I was thinking, but how do I do that.  I would need the program that generates that type of document.

One thing I am not sure about with the streamReader object is that if I point it at a Word doc I get something back, but of course it cannot be read.  So how do I differentiate.
By program type, I meant functionality wise.
The program is going to upload the file to a database.  Before it is uploaded certain properties of the file need to be added.  if I can read the text of the file I can fill out many of the properties for the user.
With streamreader, you would not be able to distinguish between file types. Try using the IO.File.ReadAllText and see if it raises an error for binary files.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Give the stackoverflow thread a try.
by the way thanks CodeCruiser for picking up yet another one of my questions.
When asking this question I did not realise how much of a question it is.  The question is not easy to answer and you will find many discussions on this.

CodeCruisers answer whilst simplistic is essentially the answer.  I have marked one of my comments as answer as well as you can see the thread from stackoverflow which basically has a discussion on this topic.