Using Write method
using System.IO;
using System;
class WriteFile
{
static void Main()
{
//The Write method does not append a newline as done by WriteLine method.
FileStream fs = new FileStream("D://MyFile.txt", FileMode.Create);
fs.Close();
Console.WriteLine("File Created Sucessfully");
StreamWriter writer = new StreamWriter("D://MyFile.txt");
writer.Write("Word 1");
writer.Write("word 2");
writer.Flush();
Console.WriteLine("Written to file Sucessfully");
Console.ReadLine();
}
}
Output:
File Created Successfully
Written to file Successfully