Create a File in VB.NET

How to Create a File in VB.NET?


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

Imports System.IO
Module Module1
Sub Main()
Dim w As StreamWriter
w = File.CreateText("C:sample.txt")
End Sub
End Module

In the above example, a file sample.txt is created using the File.CreateText method and the StreamWriter class.

Visual Basic Tutorial

Ask Questions

Ask Question