FileSystem.FreeFile Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns an Integer
value that represents the next file number available for use by the FileOpen
function.
public:
static int FreeFile();
public static int FreeFile ();
static member FreeFile : unit -> int
Public Function FreeFile () As Integer
An integer value that represents the next file number available for use by the FileOpen
function.
More than 255 files are in use.
This example uses the FreeFile
function to return the next available file number. Five files are opened for output within the loop, and some sample data is written to each.
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
Use FreeFile
to supply a file number that is not already being used.
Product | Versions |
---|---|
.NET | Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: