private static void PrepareUpload(RestBase request, string path) { var startIndex = path.IndexOf("?status=", StringComparison.Ordinal) + 8; var endIndex = path.IndexOf("&pic=", StringComparison.Ordinal); request.Method = WebMethod.Post; string status = path.Substring(startIndex, endIndex - startIndex); request.AddField("status", status); // https://upload.api.weibo.com/2/statuses/upload.json startIndex = path.IndexOf("&pic=", StringComparison.Ordinal) + 5; endIndex = path.Trim().Length; var uri = path.Substring(startIndex, endIndex - startIndex); path = path.Remove(path.IndexOf("?status=")); request.Path = path; var file = new FileStream(Uri.UnescapeDataString(uri), FileMode.Open); request.AddFile("pic", Path.GetFileName(Uri.UnescapeDataString(uri)), file, "image/jpeg"); }