您的位置:首页 > Web前端 > JavaScript

C# 生成js文件

2009-04-16 18:13 260 查看
//假设要生成的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();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: