小编Abd*_*MAL的帖子

文件下载问题:文件名被空格截断!

当我正在使用以下代码从服务器下载文件:

Response.AddHeader("Content-Disposition", "attachment; filename=" + 
Server.UrlPathEncode(Path.GetFileName(_Filename)));
Run Code Online (Sandbox Code Playgroud)

问题是在文件名中有空格时,使用此代码,服务器会在找到第一个空格时自动拆分!

我希望知道为什么以及解决方案是什么?

asp.net c#-4.0

16
推荐指数
2
解决办法
1万
查看次数

编码问题

我想将数据从DaraGrid导出到Excel文件中.用法语提供这些数据在这里,你是我的方法:

public static void ExportGridView( DataGrid dataGrid, string fileName)
    {
        HttpResponse m_Response = HttpContext.Current.Response;
        m_Response.Clear();
        m_Response.AddHeader("content-disposition",
            string.Format("attachment;filename={0}", fileName));
        m_Response.Charset = "";           
        m_Response.ContentType = "application/octet-stream"; //"application/vnd.xls";
        m_Response.ContentEncoding = Encoding.UTF32;
        StringWriter stringWrite = new StringWriter();
        HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
        dataGrid.RenderControl(htmlWrite);
        m_Response.Write(stringWrite.ToString());
        m_Response.End();

}
Run Code Online (Sandbox Code Playgroud)

否则输出不是良好的法语格式

例)

Engagé=>engagé

Société=>Société

c#-3.0

1
推荐指数
1
解决办法
3445
查看次数

标签 统计

asp.net ×1

c#-3.0 ×1

c#-4.0 ×1