Mega Code Archive

 
Categories / VB.Net / File Directory
 

File AppendAllText opens a file, appends string to the file, and then closes the file

Imports System Imports System.IO Imports System.Text Public Class Test     Public Shared Sub Main()         Dim path As String = "c:\temp\MyTest.txt"         If File.Exists(path) = False Then             Dim createText As String = "Hello and Welcome" + Environment.NewLine             File.WriteAllText(path, createText)         End If         Dim appendText As String = "This is extra text" + Environment.NewLine         File.AppendAllText(path, appendText)         Dim readText As String = File.ReadAllText(path)         Console.WriteLine(readText)     End Sub End Class