EscapeDataString URI 字串太長
阿新 • • 發佈:2018-11-11
/// <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(); }