This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / 哪位.net大侠给个文件download的sample吧,我用WebClient.OpenRead()总不能弹出下载提示对话框。用NetWorkStream还要用sockets,麻烦。我就是要把服务器本地的file下载到客户的机器上用excel打开,文件类型是csv。
-mfcguy();
2008-8-13
{108}
(#4616318@0)
-
WebClient..::.DownloadFile Method (String, String)
-readonly(ReadOnly);
2008-8-13
(#4616364@0)
-
same result, no dialog poped up for downloading.
-mfcguy();
2008-8-13
(#4616425@0)
-
我搞定了,先在server端生成sample.csv文件,记住操作之后关闭文件,然后用下面的几行code就可以弹出保存文件的对话框。Response.Clear();
Response.ContentType = "application/vdc.ms-excel";
Response.AddHeader("content-disposition", "attachment;filename=sample.csv");
Response.Charset = string.Empty;
Response.WriteFile("sample.csv");
Response.Flush();
Response.End();
-mfcguy();
2008-8-13
{332}
(#4616481@0)
-
弄明白你的意思了,不过不明白为何要让WebClient.OpenRead()弹出下载提示对话框,你就不能先弹个对话框来决定是否call WebClient.OpenRead()?
-readonly(ReadOnly);
2008-8-13
(#4616508@0)
-
我开始以为WebClient.OpenRead可以实现弹出对话框保存或者打开文件。
-mfcguy();
2008-8-13
(#4616518@0)