All pastes #201385 Raw Edit

post

public text v1 · immutable
#201385 ·published 2006-10-13 20:35 UTC
rendered paste body
try
            {

                ASCIIEncoding encoding = new ASCIIEncoding();
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://www.yourwebsite.com/");
                webRequest.Timeout = 6000;
                webRequest.Method = "post";
                webRequest.ContentType = "application/x-www-form-urlencoded";
                //string postData = "version=" + 6;
		//your post data ^^^^^^^^^^^^^
                byte[] data = encoding.GetBytes(postData);
                webRequest.ContentLength = data.Length;
                Stream newStream = webRequest.GetRequestStream();
                newStream.Write(data, 0, data.Length);
                newStream.Close();
                HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
                Stream responseStream = webResponse.GetResponseStream();
                string responseEncoding = webResponse.ContentEncoding.Trim();
                if (responseEncoding.Length == 0)
                {
                    responseEncoding = "us-ascii";
                }
                StreamReader responseReader = new StreamReader(responseStream, System.Text.Encoding.GetEncoding(responseEncoding));
                string answer = responseReader.ReadToEnd();
            }
            catch
            {
                MessageBox.Show("Could not connect to update server.");
                ChangeMessage("No updates found.");
            }