Tuesday, August 16, 2011

How to create a text File in C#.Net

Program to create a text File in C#.Net:-



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;

namespace CreateFileByManishAgrahari
{
    class CreateFile
    {
        static void Main(string[] args)
        {
            // Compose a string that consists of three lines.
            string lines = "First line.\r\nSecond line.\r\nThird line.";

            // Write the string to a file.
            StreamWriter file = new System.IO.StreamWriter("c:\\test.txt");
            file.WriteLine(lines);

            file.Close();
        }
    }
}









0 comments: