FileSystem.FileClose(Int32[]) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
結束對使用函 FileOpen 式開啟的檔案的輸入/輸出(I/O)。
My 這樣能提升檔案 I/O 作業的生產力與效能。 如需相關資訊,請參閱 FileSystem 。
public:
static void FileClose(... cli::array <int> ^ FileNumbers);
public static void FileClose(params int[] FileNumbers);
static member FileClose : int[] -> unit
Public Sub FileClose (ParamArray FileNumbers As Integer())
參數
- FileNumbers
- Int32[]
Optional. 參數陣列,包含 0 個或更多通道,需關閉。
例外狀況
FileNumber 不存在。
範例
此範例使用FileClose函數關閉開啟的檔案。Input
Dim TextLine As String
FileOpen(1, "TESTFILE", OpenMode.Input) ' Open file.
Do While Not EOF(1) ' Loop until end of file.
TextLine = LineInput(1) ' Read line into variable.
MsgBox(TextLine) ' Display the line
Loop
FileClose(1) ' Close file.
備註
此功能 FileClose 是為了向下相容而設計,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 更多資訊請參見
如果你省略 FileNumbers了 ,該函式開啟 FileOpen 的所有活動檔案都會被關閉。
當你關閉為或開啟的OutputAppend檔案時,最終的輸出緩衝區會寫入該檔案的作業系統緩衝區。 所有與關閉檔案相關的緩衝區空間都會被釋放。
當 FileClose 該函式執行時,檔案與其檔案號的關聯即告終止。