Cuncurent多次下载 [英] Cuncurent Multiple download

查看:76
本文介绍了Cuncurent多次下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何同时下载多个文件.页面具有多个链接以下载不同的文件.一次单击多个链接时,第一个文件开始下载.当第一个文件进行时,第二个文件应启动以开始下载.但在第一个文件下载完成后,第二个文件将开始下载.同时页面也应该起作用(回发).

以下是我的代码:

Hi,

How to download the multiple files at the same time. Page has multiple link to download the different file. when click multiple link at a time, the first file started to download. when first file is in progress, the second file should initiate to start download. but second file is start to download after first file download completed. at the same time page also should work(postback).

below is my code:

FileInfo fileInfo = new FileInfo(path);
//Clearing the content from cache
Response.ClearContent();
// Add the file name and attachment, which will force the open/cancel/save dialog box to show, to the header
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name);
// Add the file size into the response header
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
//For Https
Response.AddHeader("cache-control", "private");
Response.AddHeader("pragma", "private");
Response.ContentType = "application/vnd.ms-excel";

if (!String.IsNullOrEmpty(Request.QueryString["fileType"]))
{
    Response.ContentType = MimeType(path);
}

//Response.WriteFile(path);
Response.TransmitFile(path);

Response.Flush();
//Response.End(); or Response.Close(); until ending or closing the Response the file will not get downloaded
Response.End()

;

谢谢&问候,
萨拉瓦南


[edit]已添加代码块-OriginalGriff [/edit]

;

Thanks & Regards,
Saravanan


[edit]Code block added - OriginalGriff[/edit]

推荐答案

您需要在新线程中执行每次下载.最好的方法(如果使用的是.net 4)是使用TPL同时下载多个文件.

看一下这个链接:

http://blogs.msdn.com/b/pfxteam/archive/2010/05/04/10007557.aspx [ ^ ]



http://www.informit.com/guides/content.aspx?g=dotnet& seqNum = 866 [ ^ ]
You need to execute each download in a new thread. The best way (if you are using .net 4) is to use TPL to download multiple files at the same time.

take a look at this link:

http://blogs.msdn.com/b/pfxteam/archive/2010/05/04/10007557.aspx[^]

or

http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=866[^]


这篇关于Cuncurent多次下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆