File Handling in VB.NET

G

Guest

Jody:

Dim lsFileContent as String

'Opens the file name referred to as sFileName.
Dim lfsTemp = New FileStream(sFileName, IO.FileMode.Open)

'Creates a Binary reader object.
Dim lbrTemp = New BinaryReader(lfsTemp)

'Reads all the bytes.
Dim lbTemp = lbrTemp.ReadBytes(lbrTemp.BaseStream.Length)

' Since I am reading bytes, they could also be multi-byte and
' this method uses the encoding to convert the bytes read to a
string
lsFileContent = System.Text.Encoding.Default.GetString(lbTemp)

lfsTemp.Close
lbrTemp.Close

Hope this helps.

Venki
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top