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 the user hereCodeTo initialize the page
Write_file (file_name );
}
// method for creating a file, and enter the content in the file
Public void write_file (string file_name)
{< br> If (file. exists (file_name)
{< br> console. writeline ("{0} already exists. ", file_name);
return;
}< br> streamwriter sr = file. createtext (file_name);
Sr. writeline ("this is my first Program . ");
Sr. writeline ("by zixian2005");
Sr. close ();
}
# Code generated by region web Form Designer
Override protected void oninit (eventargs E)
{
//
// Codegen: This call is required by the ASP. NET web form designer.
//
Initializecomponent ();
Base. oninit (E );
}
/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void initializecomponent ()
{
This. Load + = new system. eventhandler (this. page_load );
}
# Endregion
}
}