File encoding and VB.NET

mivey4

Member
Joined
Mar 29, 2005
Messages
11
Programming Experience
1-3
I have created an app that reads log and text files using the following logic so the file is properly read.

For text files I simply using StreamReader:

Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader
oRead = oFile.OpenText(lblFileName.Text)rtxtDisplay.Text = oRead.ReadToEnd

For log files I use the richTextBox controls loadFile method to force unicode decoding method:

rtxtDisplay.LoadFile(lblFileName.Text, RichTextBoxStreamType.UnicodePlainText)

This usually will work well for most files of either extension unless the file is USING ANSI encoding, since the logic can't determine by the files extension which method of encoding the file has.

Is there a way that VB.NET can determine the encoding a file uses so I may implement the appropriate logic in my code to have the file properly decoded?
I am certain there must be some way possible since notepad performs the task effortlessly.

Help plz.
 
Back
Top