Create a File in VB.NET
How to Create a File in VB.NET?
Explanation
Create a File in VB.NET 2008.
To
Create a File in VB.NET, the
FileStream Class is used. The members of this class
FileAccess,
FileMode,
FileShare enumerations along with constructors are used to open or create or share a file. Then using the
classes
StreamReader,
StreamWriter are used to modify the file data
Example:
Imports System.IO
Module Module1
Sub Main()
Dim w As StreamWriter
w = File.CreateText("C:sample.txt")
w.Flush()
w.Close()
End Sub
End Module
Description:
In the above example, a file sample.txt is created using the
File.CreateText method and the
StreamWriter class.