FileSystem.FreeFile 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳 Integer 一個代表下一個可供函式使用的 FileOpen 檔案號的值。
public:
static int FreeFile();
public static int FreeFile();
static member FreeFile : unit -> int
Public Function FreeFile () As Integer
傳回
一個整數值,代表函式下一個可用的 FileOpen 檔案號。
例外狀況
目前有超過 255 個檔案被使用。
範例
此範例使用 FreeFile 函式回傳下一個可用的檔案號碼。 迴圈中會開啟五個檔案輸出,並寫入部分樣本資料。
Dim count As Integer
Dim fileNumber As Integer
For count = 1 To 5
fileNumber = FreeFile()
FileOpen(fileNumber, "TEST" & count & ".TXT", OpenMode.Output)
PrintLine(fileNumber, "This is a sample.")
FileClose(fileNumber)
Next
備註
用來 FreeFile 提供尚未被使用的檔案號碼。