如何在asp.net中的某个位置保存csv文件 [英] How to save a csv file in a location in asp.net
本文介绍了如何在asp.net中的某个位置保存csv文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有代码,我必须一次将div的元素转换为多个csv文件。现在我想要的是所有文件都应该保存在代码的预定义位置。我不想要下载选项来保存这些文件,例如如果有10个文件,则它们应保存在预定义的驱动器中,如C:\ temp \ folder。
如何实现这个?
先谢谢
Hi All,
I have code in which I have to convert elements of div into multiple csv file at a time. Now what I want is that all the files should be saved at a predefined location from code. I don't want download option to save these files e.g. if there are 10 files then they should be save in a predefined drive like C:\temp\folder.
How to implement this?
Thanks in Advance
推荐答案
按照下面的代码这里我保存了我的csv文件C:\驱动器,
strcontent是你要在csv文件中保存的内容
< br $> b $ b
follow below code here i have saved my csv file C:\ drive,
strcontent is the content which you want to save in csv file
try
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=Report.csv");
Response.ContentType = "application/octet-stream";
Response.Write(strContent);
Response.End();
}
catch (System.Threading.ThreadAbortException ex)
{
StreamWriter sw = new StreamWriter(@"c:/Report.csv");
sw.Write(strContent);
sw.Close();
System.IO.FileInfo fileInfo = new FileInfo(@"c:/");
fileInfo.Delete();
}
这篇关于如何在asp.net中的某个位置保存csv文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文