1. 程式人生 > >EscapeDataString URI 字串太長

EscapeDataString URI 字串太長

        /// <summary>
        /// 處理  無效的 URI: URI 字串太長。問題
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        static string MyEscapeDataString(string value)
        {
            int limit = 4000;
            StringBuilder sb 
= new StringBuilder(); int loops = value.Length / limit; for (int i = 0; i <= loops; i++) { sb.Append(i < loops ? Uri.EscapeDataString(value.Substring(limit * i, limit)) : Uri.EscapeDataString(value.Substring(limit
* i))); } return sb.ToString(); }