Text file Write with format and write boolean value to a text file
using System;
using System.IO;
class Class1{
static void Main(string[] args){
try
{
FileStream aFile = new FileStream("practice.txt",FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(aFile);
bool truth = true;
sw.WriteLine("A");
sw.WriteLine("{0}",System.DateTime.Now.ToShortDateString());
sw.Write("A");
sw.Write("www.java2s.com",truth);
sw.Close();
}
catch(IOException e)
{
Console.WriteLine("An IO exception has been thrown!");
Console.WriteLine(e.ToString());
Console.ReadLine();
return;
}
return;
}
}
Related examples in the same category