当前位置:编程学习 > C#/ASP.NET >>

如何把文件下载链接保存到Application中?

Application["TalkContent"] += "请点击证据:" + "<span style='color: #ff0033;'>" + "<label onclick='document.getElementById(\"btn_DownLoad\").click();'>" + strFileName + "</label>" + "</span>" + " " + "进行下载!" + "<br>";

保存需要下载文件的链接到Application中
以下是下载文件的方法:
    protected void btn_DownLoad_Click(object sender, EventArgs e)
    {
        string strFileUploadPath = ConfigurationManager.AppSettings["FileUplodePath"].ToLower();
        string strFileName = lb_FileList.SelectedValue;
        string FullFileName = Server.MapPath(strFileUploadPath + "/") + strFileName;

        FileInfo DownloadFile = new FileInfo(FullFileName);
        Response.Clear();

        Response.Charset = "utf-8";
        Response.Buffer = true;
        this.EnableViewState = false;
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        Response.AppendHeader("Content-Disposition", "attachment;filename=" + strFileName);
        Response.ContentType = "application/octet-stream";
        Response.WriteFile(FullFileName);
        Response.Flush();
        Response.Close();
        Response.End();
    }
但是Application读出来的链接,其他用户打开这个页面时,点击不起反应~~ --------------------编程问答-------------------- 保存文件地址就可
string path = Server.MapPath("~/") + “”;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(FileName, System.Text.Encoding.GetEncoding("utf-8"))  + "." + obj.AttachmentExt);
Response.ContentType = "application/octet-stream";
Response.WriteFile("" + path + "");
Response.End(); --------------------编程问答-------------------- 不好意思,您可能误解我的意思了

想实现的效果是,A用户点击某文件,运行以上代码,页面生成一个下载文件的链接,其他用户登入时,进入同一个页面(类似聊天室),可以点击页面这个链接,下载文件。

上面代码只是说,A用户点击页面某控件,触发btn_DownLoad_Click事件,在页面生成一个下载链接,可是这个链接也就A用户能用,其他用户同时进入这个页面时,点击则获取不到这个地址。

本人还以为说保存到Application中,其他用户也可以点击下载这个链接地址。 --------------------编程问答-------------------- mark!!! --------------------编程问答-------------------- mark!!!
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,