日期:2014-05-18  浏览次数:20546 次

怎么自动生成文件。
我想写个程序要其自动生成以.sql为后缀名的文件,里面的内容是一段查询语句或者存储过程。

------解决方案--------------------
C# code

        Response.Clear();
        Response.Buffer = false;
        Response.AppendHeader("Content-Disposition", "attachment;filename=file.sql");
        Response.ContentType = "text/sql";
        System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
        oStringWriter.Write("test");
        oStringWriter.Flush();
        oStringWriter.Close();
        Response.Write(oStringWriter.ToString());
        Response.End();