File.WriteAllText()
This is a static strategy for “Document” class, which is utilized to compose all content (went as a contention) in a record. Note: If the record doesn’t exist at a predetermined area, this technique makes the document first and afterwards compose all content to the document.
Program:
using System;
//We need to include this namespace for file handling.
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
string s;
Console.WriteLine("Enter text to Write into File : ");
s = Console.ReadLine();
File.WriteAllText("ABC.TXT",s);
Console.WriteLine("\nFile Creation Done");
}
}
}
Output
Enter text to Write into File :
Hello , This is a sample program for writing text into file.
File Creation Done