Mega Code Archive

 
Categories / VB.Net / File Directory
 

File Create creates or overwrites the specified file

Imports System Imports System.IO Imports System.Text Public Class Test     Public Shared Sub Main()         Dim path As String = "c:\MyTest.txt"         If File.Exists(path) Then             File.Delete(path)         End If         Dim fs As FileStream = File.Create(path, 1024)         Dim info As Byte() = New UTF8Encoding(True).GetBytes("This is some text in the file.")         fs.Write(info, 0, info.Length)         fs.Close()         Dim sr As StreamReader = File.OpenText(path)         Do While sr.Peek() >= 0             Console.WriteLine(sr.ReadLine())         Loop         sr.Close()     End Sub End Class