How to: Create a File in Visual Basic
This example creates an empty text file at the specified path using themethod in the class.
Compiling the Code
Use the file variable to write to the file.
If the file already exists, it is replaced.
The following conditions may cause an exception:
The path name is malformed. For example, it contains illegal characters or is only white space ().
The path is read-only ().
The path name is Nothing ().
The path name is too long ().
The path is invalid ().
The path is only a colon ":" ().
Amay be thrown in partial-trust environments.
The call to the Create method requires.
Anis thrown if the user does not have permission to create the file.