按一下以給予評分及指教
MSDN
MSDN Library
Visual Basic
函式
D-G 函式
 FileClose 函式

  開啟低頻寬檢視
本頁僅適用於
Microsoft Visual Studio 2005/.NET Framework 2.0

其他版本也適用於下列軟體:
Visual Basic 語言參考
FileClose 函式

將輸入/輸出 (I/O) 結果導向至使用 FileOpen 函式開啟的檔案。

使用 My 給您更大的檔案 I/O 作業產能和效能。如需詳細資訊,請參閱 My.Computer.FileSystem 物件

Public Sub FileClose(ParamArray FileNumbers() As Integer)

參數

FileNumbers

選擇項。將關閉的 0 或多個通道的參數陣列。

例外狀況類型 錯誤代碼 條件

IOException

52

FileNumber 不存在。

如果將使用非結構化錯誤處理的 Visual Basic 6.0 應用程式升級,請參閱「錯誤代碼」資料行 (您可以將錯誤代碼與 Number 屬性 (Err 物件) 比對)。但是,請盡可能考慮以 Visual Basic 的結構化例外處理概觀 取代這類錯誤控制項。

提供 FileClose 函式以取得回溯相容性 (Backward Compatibility),但可能會影響效能。對於非舊版應用程式,My.Computer.FileSystem 物件會提供更好的效能。如需詳細資訊,請參閱使用 Visual Basic 存取檔案

如果您省略了 FileNumbers,則由 FileOpen 函式所開啟的所有使用中檔案都會關閉。

當您關閉為 OutputAppend 開啟的檔案時,輸出的最後緩衝區會寫入該檔案的作業系統緩衝區中。所有與已關閉之檔案相關聯的緩衝區空間都會被釋放。

執行 FileClose 函式時,檔案與其檔案號碼間的關聯也將中斷。

這個範例會使用 FileClose 函式關閉為 Input 開啟的檔案。

Visual Basic
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.

不支援這個函式。

命名空間 (Namespace)︰Microsoft.VisualBasic

模組︰ FileSystem

組件 (Assembly):Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

社群內容   什麼是社群內容?
新增內容 RSS  註解
Processing
© 2009 Microsoft Corporation. 著作權所有,並保留一切權利。 使用規定  |  商標  |  隱私權聲明
Page view tracker