public void makeHtml1(string flname, string fname, string ftext)
{
//string _FileDir = HttpContext.Current.Server.MapPath(Path.GetDirectoryName(fname));
string _FileDir = @"d:\"+flname+@"\";
//创建文件夹
if (!Directory.Exists(@_FileDir))
{
Directory.CreateDirectory(@_FileDir);
}
Encoding code = Encoding.GetEncoding("Gb2312");
//创建文件
string phyPath = _FileDir + fname;
string OldString = "";
OldString = OldString + ftext;
System.IO.StreamWriter sw = new System.IO.StreamWriter(phyPath, false, code);
sw.Write(ftext);
sw.Flush();
sw.Close();
sw.Dispose();
HttpContext.Current.Response.Write("成功生成:" + fname);
}
protected void Button1_Click(object sender, EventArgs e)
{
string fl = this.TextBox3.Text;//文件夹
string aa = this.TextBox1.Text;//文件
string ss = aa + ".html";
string content = this.TextBox2.Text;//内容
makeHtml1(fl, ss, content);
}
本文作者:网友 来源: http://hi.baidu.com/rose%BE%B4/blog/
CIO之家 www.ciozj.com 微信公众号:imciow