Syntax
void WriteAllLines(string filename);
Program
using System;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
string[] line={
"Sample Line 1",
"Sample Line 2",
"Sample Line 3",
"Sample Line 4",
"Sample Line 5"
};
File.WriteAllLines("sample.txt", line);
Console.WriteLine("Data written successfully");
}
}
}
Output
Data written successfully