rt就是希望 在IE 中打开 txt 文件时,实现 下载 该txt文件 或 把这个txt文件 另存为 这个功能

解决方案 »

  1.   

    不能直接超连 .txt 文件的地址。参考:string strPathServer = this.p_strFtpFilePath + "\\";
    string strFileServerName = e.Item.Cells[4].Text;
    string contentType = "application/";  
    string strFileSaveName = ((LinkButton)e.Item.FindControl("BtnAttachName")).Text;
    DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
    diskOpts.DiskFileName = strPathServer + strFileServerName;HttpContext.Current.Response.Clear();
    HttpContext.Current.Response.Charset ="GB2312";
    HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + strFileSaveName);
    HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
    HttpContext.Current.Response.ContentType = contentType;
    HttpContext.Current.Response.WriteFile(diskOpts.DiskFileName);
    HttpContext.Current.Response.End();