this.Response.Write("<a href='xxxxx.rar'>文件名</a>");

解决方案 »

  1.   

    得到所有文件的数组
     String[] files = Directory.GetFiles(directoryPath);
    遍历数组,得到文件的名字,生成这样的格式
    down.aspx?name=filename关于下载,网上有很多代码,在此不重复。搜索asp.net 下载文件
      

  2.   

    动态生成LinkButton控件,动态添加事件调用一个方法Public Sub Download(ByVal oResponse As System.Web.HttpResponse, ByVal FileName As String, ByVal strFileNamePrompt As String)
    Dim oFile As System.IO.FileInfo = New System.IO.FileInfo(FileName)
    oResponse.AddHeader("Content-Disposition", "attachment;filename=" & HttpUtility.UrlEncode(strFileNamePrompt))
    oResponse.AddHeader("Content-Length", oFile.Length.ToString())
    oResponse.ContentType = "APPLICATION/OCTET-STREAM"
    oResponse.WriteFile(oFile.FullName)
    oResponse.End()
    End Sub
      

  3.   

    td.Controls.Add(new LiteralControl("<a href="+FileName+">"+FileName+"</a>")); 请问如何将这个超链接实现点击文件名之后下载??
      

  4.   

    请问如何将这个超链接实现点击文件名之后下载??
    http://support.microsoft.com/kb/812406/zh-cn
      

  5.   

    http://www.microsoft.com/china/msdn/library/webservices/asp.net/WebDownloads.mspx
      

  6.   

    http://www.wangwa.com/info/2006-07/11001.htm
      

  7.   

    public void DownLoadFiles(string fullName)
    {
    // retrieve the path of the file to download, and create
    // a FileInfo object to read its properties
    string path = Server.MapPath("../Files/"+fullName);
    System.IO.FileInfo file = new System.IO.FileInfo(path);
    string subName = file.Name.Substring(14);
    string fileName = subName.Substring(0,subName.LastIndexOf("."));
    string Ext  = subName.Substring(subName.LastIndexOf("."));
    // clear the current output content from the buffer
    Response.Clear();
    // add the header that specifies the default filename for the Download/SaveAs dialog //设置此句,防止下载对话框中的选项在中文标题时,出现乱码。
    Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(fileName)+ Ext);
    // add the header that specifies the file size, so that the browser
    // can show the download progress

    //设置为中文,防止乱码,相当于Response.AddHeader("Content-type", "text/html;Charset=GB2312");
    Response.Charset = "GB2312";
    //设置输出流为简体中文输出流。
    Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312"); Response.AddHeader("Content-Length", file.Length.ToString());
    // specify that the response is a stream that cannot be read by the
    // client and must be downloaded
    Response.ContentType = "application/octet-stream";
    // send the file stream to the client
    Response.WriteFile(file.FullName);
    // stop the execution of this page
    Response.End(); }
      

  8.   

    <a href="file:\\192.168.16.51\f$\aa\WindowsApplication1.rar">
      

  9.   

    <a href=""></a>这样好