VB.Net by API/System.IO/FileMode — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 12:50, 26 мая 2010

FileMode.Open

  
Imports System.IO

Public Class Tester
    Public Shared Sub Main
        Dim f As System.IO.FileStream
        Dim r As System.IO.StreamReader
        Dim mylength As Integer
        Dim i As Integer
        f = New System.IO.FileStream("test.txt", IO.FileMode.Open, IO.FileAccess.Read)
        r = New System.IO.StreamReader(f)
        Console.WriteLine(r.ReadToEnd())
        f.Close()
        r.Close()
    End Sub
End Class


FileMode.OpenOrCreate

  
 
Imports System.IO

Public Class Tester
    Public Shared Sub Main
        Dim fs As System.IO.FileStream
        Dim w As System.IO.BinaryWriter
        Dim buffer As String
        Dim c As Char
        c = Chr(9)
        fs = New System.IO.FileStream("test.txt", IO.FileMode.OpenOrCreate)
        w = New System.IO.BinaryWriter(fs)
        w.Seek(0, System.IO.SeekOrigin.Begin)
        w.Write("writing data via BinaryWriter")
        w.Close()
        fs.Close()
    End Sub
End Class