How do you read a non-Text file as a text file using StreamReader?

Denaes

Well-known member
Joined
Jun 10, 2003
Messages
956
Dont ask me why, but the Wordperfect dll that comes with wordperfect 2002 worked with vb6, but not with vb.net.

I wont let that get in my way... I need to search for a particular string and grab the next 11 characters after that. I could do that without much of a problem, but I did hit a little snag.

using the Streamreader with this code:


Code:
        Dim sr As StreamReader = New StreamReader(New FileStream(path, FileMode.Open)) 
        TextBox1.AppendText(sr.ReadToEnd) 
        sr.Close()


I get the answer of "WPCP", which is the 2nd through the 5th characters of the document, read in a text editor. There is like 10 pages of text.

If I change the file extension to .txt, I get the entire document and I can search for my string and grab out the 11 characters I need.

Is there a way to force the streamreader to read like a text document without changing the file extension?

As a last ditch, show something to the boss, solution I can locate the filename, change it to .txt, open and scan, then change back to .wpd...

but thats two more lines of code than should be needed and actually might slow down the program over 900 programs worth of time.

If anyone can figure how to make it open any file type as if it were a text file, Id be very happy
 
Back
Top