//假设要生成的JS文件为:xyz.js
string path = Server.MapPath("../js/xyz.js   ");

// Delete the file if it exists.
if (File.Exists(path))
{
File.Delete(path);
}

// Create the file.
StreamWriter sr = File.CreateText(path);
sr.WriteLine ("function   f1()");
sr.WriteLine ("{");
// 这里是f1的内容
// ……
sr.WriteLine ("}");
sr.Close();
posted on 2009-04-16 18:13  钱途无梁  阅读(726)  评论(0编辑  收藏  举报