c#匯出檔案,檔名中文亂碼解決方法

一葉、知秋發表於2018-12-28
public string clFielName(string fileName)
    {
        System.Web.HttpContext curContext = System.Web.HttpContext.Current;
        string outputFileName = null;
        string browser = curContext.Request.UserAgent.ToUpper();
        if (browser.Contains("MS") == true && browser.Contains("IE") == true)
        {
            outputFileName = System.Web.HttpUtility.UrlEncode(fileName);
        }
        else if (browser.Contains("FIREFOX") == true)
        {
            outputFileName = """ + fileName + """;
        }
        else
        {
            outputFileName = System.Web.HttpUtility.UrlEncode(fileName);
        }
        return outputFileName;
    }

原文連結:https://www.cnblogs.com/ThreeStone007/p/5401341.html

相關文章