FileStream.ReadByte Method Reads a byte from the file : FileStream « File Directory « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » File Directory » FileStreamScreenshots 
FileStream.ReadByte Method Reads a byte from the file
 

Imports Microsoft.VisualBasic
Imports System
Imports System.IO
Imports System.Text

Class FStream
    Shared Sub Main()
        Const fileName As String = "Test.dat"
        Dim dataArray(100000As Byte
        Dim randomGenerator As New Random()
        randomGenerator.NextBytes(dataArray)

        Dim fileStream As FileStream = new FileStream(fileName, FileMode.Create)
        Try
            For i As Integer = To dataArray.Length - 1
                fileStream.WriteByte(dataArray(i))
            Next i
            fileStream.Seek(0, SeekOrigin.Begin)
            For i As Integer = To CType(fileStream.Length, Integer1
                If dataArray(i<> fileStream.ReadByte() Then
                    Console.WriteLine("Error writing data.")
                    Return
                End If
            Next i
            Console.WriteLine("The data was written to {0} and verified.", fileStream.Name)
        Finally
            fileStream.Close()
        End Try

    End Sub
End Class

   
  
Related examples in the same category
1.Use FileStream to store and read fileUse FileStream to store and read file
2.Read and Write to a Newly Created Data File
3.FileStream Class
4.Create FileStream with FileMode.Append, FileAccess.Write, FileShare.Write
5.FileStream Constructor (String, FileMode, FileSystemRights, FileShare, Int32, FileOptions, FileSecurity)
6.FileStream.CanRead Property gets a value indicating whether the current stream supports reading.
7.FileStream.CanSeek Property gets a value indicating whether the current stream supports seeking.
8.FileStream.CanWrite Property gets a value indicating whether the current stream supports writing.
9.FileStream.CanRead And FileStream.CanWrite
10.FileStream.Seek Method sets the current position of this stream to the given value.
11.FileStream Class Exposes a Stream around a file
12.FileStream.CanRead Property tells whether the current stream supports reading.
13.FileStream.CanSeek Property tells whether the current stream supports seeking.
14.FileStream.CanWrite Property tells whether the current stream supports writing.
15.FileStream.Read Method Reads a block of bytes
16.FileStream.Seek Method Sets the current position of this stream to the given value.
17.Read and Write to a Newly Created Data File
w__w__w._j___a__v___a__2___s___.__c_o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.