vb.net write to text file code example
Example 1: asp.net c# write string to text file
using (StreamWriter writer = new StreamWriter("email.txt", true)) //// true to append data to the file
{
writer.WriteLine("your_data");
}
Example 2: write to text file vb.net
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter([FileName], True)
file.WriteLine([text])
file.Close()
Example 3: vbnet create and write on file
Dim strFile As String = "yourfile.txt"
Dim fileExists As Boolean = File.Exists(strFile)
Using sw As New StreamWriter(File.Open(strFile, FileMode.OpenOrCreate))
sw.WriteLine( _
IIf(fileExists, _
"Error Message in Occured at-- " & DateTime.Now, _
"Start Error Log for today"))
End Using
Example 4: write to text file vb.net
Dim [FileVar] As String = Application.StartupPath & "/[FileName]"
FileOpen(1, [FileVar], OpenMode.Append)
PrintLine(1, text)
FileClose(1)