FileSystem.EOF 方法
當已經到達為 Random 或循序 Input 開啟的檔案之結尾時,傳回布林值 (Boolean) True。
命名空間: Microsoft.VisualBasic
組件: Microsoft.VisualBasic (在 microsoft.visualbasic.dll 中)
語法
'宣告
Public Shared Function EOF ( _
FileNumber As Integer _
) As Boolean
'用途
Dim FileNumber As Integer
Dim returnValue As Boolean
returnValue = FileSystem.EOF(FileNumber)
public static bool EOF (
int FileNumber
)
public:
static bool EOF (
int FileNumber
)
public static boolean EOF (
int FileNumber
)
public static function EOF (
FileNumber : int
) : boolean
參數
- FileNumber
必要項。包含任何有效檔案編號的 Integer。
傳回值
當已經到達為 Random 或循序 Input 開啟的檔案之結尾時,傳回布林值 (Boolean) True。
備註
如需詳細資訊,請參閱 Visual Basic 的主題 EOF 函式。
使用 EOF 來避免因為嘗試取得超過檔案結尾的輸入所產生的錯誤。
EOF 函式在到達檔案結尾之前,都會傳回 False。為 Random 或 Binary 存取開啟檔案之後,EOF 在最後執行的 FileGet 函式無法讀取整個資料錄之前,都會傳回 False。
為 Binary 存取開啟檔案之後,嘗試使用 Input 函式來讀取整個檔案的動作在 EOF 傳回 True 之前會產生錯誤。以 Input 讀取二進位檔案 (Binary File) 時,請使用 LOF 和 Loc 函式來取代 EOF,或在使用 EOF 函式時使用 Get。為 Output 開啟檔案之後,EOF 一定會傳回 True。
範例
這個範例使用 EOF 函式來偵測檔案的結尾。此範例假設 Testfile
是一個具有幾行文字的文字檔。
Dim TextLine As String
' Open file.
FileOpen(1, "TESTFILE", OpenMode.Input)
' Loop until end of file.
Do While Not EOF(1)
' Read line into variable.
TextLine = LineInput(1)
' Display result in a message box.
MsgBox("End of file reached at " & TextLine)
Loop
FileClose(1)
平台
Windows 98、 Windows 2000 SP4、 Windows Millennium Edition、 Windows Server 2003、 Windows XP Media Center Edition、 Windows XP Professional x64 Edition、 Windows XP SP2、 Windows XP Starter Edition
.NET Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱系統需求一節的內容。
版本資訊
.NET Framework
支援版本:2.0、1.1、1.0
請參閱
參考
FileSystem 類別
FileSystem 成員
Microsoft.VisualBasic 命名空間
IOException