//假设要生成的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();
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();