This article describes the ASP.net StreamReader to create a file instance code, you need friends can refer to the
copy code code as follows:
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; A summary description of the
namespace New_app
{
///<summary>
///myXML.
///</summary>
public class myxml:System.Web.UI.Page
{
Private Const STR ing file_name = "d:myfile.txt";
private void Page_Load (object sender, System.EventArgs e)
{
//Place user code here to initialize the page &nbs p;
write_file (file_name);
}
//A method of creating a file and entering content in a 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");
Sr. Close ();
}
#region The code generated by the Web Forms Designer
override protected void OnInit (EventArgs e)
{
//
//CodeGen: This call is required for the ASP.net Web forms Designer.
//
InitializeComponent ();
base. OnInit (e);
}
///<summary>
///Designer supports the desired method-do not use the Code Editor to modify
///The contents of this method.
///</summary>
private void InitializeComponent ()
{
this. Load + = new System.EventHandler (this. Page_Load);
}
#endregion
}
}