private static void WriteMultipartFormData(Stream stream, string boundary, KeyValuePair<string, object>[] prm) { var items = prm.ConvertAll(x => MultipartItem.Create(x.Key, x.Value)); // Start writing foreach(var x in items) { stream.WriteString("--" + boundary + "\r\n"); x.WriteTo(stream); stream.WriteString("\r\n"); } stream.WriteString("--" + boundary + "--"); }