VB.Net/File Directory/File Open Mode

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

Open File in an Input, Read, and Shared Mode

Imports System
Imports System.Collections.ObjectModel
Imports System.IO
Public Class MainClass
   Shared Sub Main()
        " Get an available file number.
        Dim file_num As Integer = FreeFile()
        " Open the file.
        Dim file_name As String = "test.txt"
        FileOpen(file_num, file_name, _
            OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
        " Read the file"s lines.
        Do While Not EOF(file_num)
            " Read a line.
            Dim txt As String = LineInput(file_num)
            Console.WriteLine(txt)
        Loop
        " Close the file.
        FileClose(file_num)
   End Sub 
End Class