Create a text file using ASP.Net C#
Here I am going to discuss about
creation of text file in ASP.Net. I have used StreamWrite class to create the
text file. This program will create a hello.txt file in your system’s D drive.
You can put your path if you wish. Str is the object of StreamWriter class. 
- strin is a object of string class
 - Write() method of StreamWrite class is used for writing a string object within a file.
 - Close() method of StreamWriter class is used for closing the file.
 
protected void Page_Load(object
sender, EventArgs e)
    {
        string
strin = "Hello world";
        StreamWriter
str = new StreamWriter("D:\\hello.txt",true);
        str.Write(strin);
        str.Close();
    }
No comments:
Post a Comment