How to Create Text file using asp.net?

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Give your new file path
FileInfo t = new FileInfo("C:/WebSite10/test.txt");
StreamWriter Tex = t.CreateText();
//Enter your text with in writeline
Tex.WriteLine("How to create Text file using asp.net");
Tex.WriteLine("www.renganathan1984.blogspot.com");
//Add new line in your text file
Tex.Write(Tex.NewLine);
Tex.WriteLine("Trichy");
Tex.WriteLine("Thiruvellarai");

Tex.Close();
Response.Write("File Succesfully created!");
}

}

No comments:

Post a Comment

Plz Share your comments...