Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void WriteBody(this WebRequest webRequest, string data)
- {
- byte[] bytes = Encoding.UTF8.GetBytes(data);
- #if WINDOWS_PHONE
- // WinPhone 7 WebRequest only supports Aync methods. Doing this is a bad idea...
- var r = webRequest.BeginGetRequestStream(result =>
- {
- var requestStream = webRequest.EndGetRequestStream(result);
- requestStream.Write(bytes, 0, bytes.Length);
- requestStream.Close();
- },
- null);
- r.AsyncWaitHandle.WaitOne();
- #else
- using (Stream requestStream = webRequest.GetRequestStream())
- {
- requestStream.Write(bytes, 0, bytes.Length);
- }
- #endif
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment