C# 解决IE文件名乱码方法

笔录

     /// <summary>
     /// 解决IE文件名乱码方法
     /// </summary>
     /// <param name="fileName">文件名</param>
     /// <returns></returns>
	public static 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://blog.csdn.net/u014353113/article/details/84784680

posted @ 2020-04-21 17:42  糯米雪梨  阅读(301)  评论(0编辑  收藏  举报