Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)aaa
published in(发表于) 2013/12/18 7:55:38
Asp.NET写文件_.net资料_编程技术

Asp.NET写文件_.net资料_编程技术-你的首页-uuhomepage.com

Asp.NET写文件的一个小实例程序。


#region 写文件
/****************************************
* 函数名称:WriteFile
* 功能说明:当文件不存时,则创建文件,并追加文件
* 参 数:Path:文件路径,Strings:文本内容
* 调用示列:
* string Path = Server.MapPath("Default2.aspx");
* string Strings = "这是我写的内容啊";
* EC.FileObj.WriteFile(Path,Strings);
*****************************************/
///


/// 写文件
///

/// 文件路径
/// 文件内容
public static void WriteFile(string Path, string Strings)
{
if (!System.IO.File.Exists(Path))
{
System.IO.FileStream f = System.IO.File.Create(Path);
f.Close();
}
System.IO.StreamWriter f2 = new System.IO.StreamWriter(Path, true, System.Text.Encoding.GetEncoding("gb2312"));
f2.WriteLine(Strings);
f2.Close();
f2.Dispose();
}
#endregion





If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759