Blog

How to write or create a text file in C#

By Owais Khan Blogs | Files, Directory, IO Sep 21, 2010
The code snippet in this blog demonstrates how to write or create a text file in C#.
Download Files: how to write text.zi

This code snippet demonstrates how to write a text file and write text on a console.

using
System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

 

namespace how_to_write_text

{

    class Program

    {

        static void Main(string[] args)

        {

            TextWriter tw = File.CreateText(@"E:\output.txt");

            tw.WriteLine("owais khan sherwani");

            Console.WriteLine("Text created");

            tw.Close();

            Console.WriteLine(Console.Read());

        }

    }

}

COMMENT USING