ASP.NET导出TXT

来源:百度知道 编辑:UC知道 时间:2024/09/21 15:36:25
我做了一个网页,要用到数据的导出,我希望把用SQL语句从SQL Server中查询出来的数据导出到TXT(数据量大,EXCEL放不下)文本中,数据分行放!
我用到的是一个按钮,只要用户单击此按钮,则弹出路径选择框,用户可以选择路径,填写文件名,然后点击确定就可以保存了!
数据库是SQL Server 2000!

控件应该都有saveas吧,直接调用就可以了啊

文件流?

很简单
我当初不会的时候也问过别人
但是别人总是不给我一个完整的可以用的东西
总是要自己整理
现在我才理解别人的行为
下面的代码你参考下吧
写程序总是要自己钻研才会记住

using (StreamWriter sw = new StreamWriter("TestFile.txt"))
{
// Add some text to the file.
sw.Write("This is the ");
sw.WriteLine("header for the file.");
sw.WriteLine("-------------------");
// Arbitrary objects can also be written to the file.
sw.Write("The date is: ");
sw.WriteLine(DateTime.Now);
}