将文件写入虚拟服务器,ASP.NET
可能的重复:
写入 CSV 文件并导出?
这可能是一个愚蠢的问题我已经在 Google 上搜索过,但无法找到明确的答案 - 如何将 CSV 文件写入网络服务器并在 C# ASP.net 中将其导出?我知道如何生成它,但我想将其保存到 www.mysite.com/my.csv,然后导出。
Possible Duplicate:
Write to CSV file and export it?
This is probably a silly question and I have searched on Google but I'm not able to find a definitive answer - how do you write a CSV file to the webserver and export it in C# ASP.net? I know how to generate it but I would like to save it to www.mysite.com/my.csv and then export it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要将 CSV 文件保存到磁盘,特别是如果它是动态生成的。您可以直接将其写入响应流,以便用户可以下载它:
您还可以编写一个 http 处理程序:
您可以像这样调用它:
http://mysite.com/csvhandler.ashx
You don't need to save the CSV file to disk especially if it is dynamically generated. You could directly write it to the response stream so that the user can download it:
You could also write an http handler:
which you would call like this:
http://mysite.com/csvhandler.ashx