Read byte array and convert it to ASCII string : FileStream « Stream File « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net Tutorial » Stream File » FileStream 
13.6.9.Read byte array and convert it to ASCII string
Imports System.Text
Imports System.IO


Public Class Tester
    Public Shared Sub Main
        Dim myFileStream As New FileStream("test.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite)
        Dim bteRead() As Byte
        Dim strRead As String
        Dim lngRead As Long

        lngRead = myFileStream.Length
        ReDim bteRead(lngRead)
        myFileStream.Read(bteRead, 0, lngRead)
        strRead = Encoding.ASCII.GetString(bteRead)
        
        Console.WriteLine(strRead)
        myFileStream.Close()
    End Sub

End Class
13.6.FileStream
13.6.1.Write Bytes using FileStream
13.6.2.Read byte using FileStream
13.6.3.Read a file by using SeekOrigin
13.6.4.Read into a buffer
13.6.5.FileStream.Length
13.6.6.Use FileStream to write byte array
13.6.7.Convert String to ASCII byte code array and save
13.6.8.Convert String to Unicode byte code array and save
13.6.9.Read byte array and convert it to ASCII string
13.6.10.Read byte array and convert it to Unicode string
13.6.11.Save UTF8Encoding string to text file
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.