0

在我的应用程序中,用户可以下载自己的文件(图像、pdf、word、...)。我使用 HttpHandel 来做。开始选择文件并下载。我希望用户可以从列表中下载所有文件。怎么做? 在此处输入图像描述

 public void ProcessRequest(HttpContext context) {

        HttpResponse response = context.Response;
        string cururl = context.Request.Url.ToString();
        int iqs = context.Request.Url.ToString().IndexOf('?');
        string querystring = (iqs < cururl.Length - 1) ? cururl.Substring(iqs + 1) : String.Empty;
        NameValueCollection parameters = HttpUtility.ParseQueryString(querystring);
        byte[] result = GetstreamForDownload(parameters);
        string fileId = context.Request.QueryString["fileId"];
        response.AddHeader("Content-disposition", "attachment; filename=" + GetFileName(parameters));
        response.ContentType = "application/octet-stream";
        response.BinaryWrite(result);

}
4

1 回答 1

0

GetstreamForDownload()当包含您parameters选择的某些键值对(例如?folderId=123&allFiles=true.

于 2013-06-08T12:29:17.103 回答