FileStream Class : FileStream « File Directory « VB.Net






FileStream Class

 

Imports System
Imports System.IO
Imports System.Text

Public Class Test
    Public Shared Sub Main()
        Dim path As String = "c:\MyTest.txt"
        If File.Exists(path) Then
            File.Delete(path)
        End If
        Dim fs As FileStream = File.Create(path)
        Dim info As Byte() = New UTF8Encoding(True).GetBytes("This is some more text,")
        fs.Write(info, 0, info.Length)

        fs.Close()
        fs = File.OpenRead(path)
        Dim b(1024) As Byte
        Dim temp As UTF8Encoding = New UTF8Encoding(True)
        Do While fs.Read(b, 0, b.Length) > 0
            Console.WriteLine(temp.GetString(b))
        Loop
        fs.Close()
    End Sub
    Private Shared Sub AddText(ByVal fs As FileStream, ByVal value As String)
    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.Create FileStream with FileMode.Append, FileAccess.Write, FileShare.Write
4.FileStream Constructor (String, FileMode, FileSystemRights, FileShare, Int32, FileOptions, FileSecurity)
5.FileStream.CanRead Property gets a value indicating whether the current stream supports reading.
6.FileStream.CanSeek Property gets a value indicating whether the current stream supports seeking.
7.FileStream.CanWrite Property gets a value indicating whether the current stream supports writing.
8.FileStream.CanRead And FileStream.CanWrite
9.FileStream.Seek Method sets the current position of this stream to the given value.
10.FileStream Class Exposes a Stream around a file
11.FileStream.CanRead Property tells whether the current stream supports reading.
12.FileStream.CanSeek Property tells whether the current stream supports seeking.
13.FileStream.CanWrite Property tells whether the current stream supports writing.
14.FileStream.Read Method Reads a block of bytes
15.FileStream.ReadByte Method Reads a byte from the file
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