Namespace used: System. IO
The file we want to create must be authorized by the asp.net user!
Using System;
Using System. Collections;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Web;
Using System. Web. SessionState;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Web. UI. HtmlControls;
Using System. Text;
Using System. IO;
Namespace new_app
{
/// <Summary>
/// Summary of myxml.
/// </Summary>
Public class myxml: System. Web. UI. Page
{
Private const string FILE_NAME = "d: MyFile.txt ";
Private void Page_Load (object sender, System. EventArgs e)
{
// Place user code here to initialize the page
Write_file (FILE_NAME );
}
// A method for creating a file and entering content in the file
Public void write_file (string FILE_NAME)
{
If (File. Exists (FILE_NAME ))
{
Console. WriteLine ("{0} already exists.", FILE_NAME );
Return;
}
StreamWriter sr = File. CreateText (FILE_NAME );
Sr. WriteLine ("this is my first program .");
Sr. WriteLine ("by zixian2005 ");