views:

90

answers:

1

I need my application to upload an output to pastebin but i cant get it to work this is the code

        WebRequest wr = WebRequest.Create(@"http://pastebin.com/api_form.php");
        ASCIIEncoding encoding = new ASCIIEncoding();
        byte[] bData = encoding.GetBytes(string.Concat("paste_code=", sOutput, "&paste_private=0&paste_expire_date=1D&paste_subdomain=c4ca4238a0b923820dcc509a6f75849b"));
        wr.Method = "POST";
        wr.ContentType = "application/x-www-form-urlencoded";
        wr.ContentLength = bData.Length;
        Stream sMyStream = wr.GetRequestStream();
        sMyStream.Write(bData, 0, bData.Length);
        sMyStream.Close();

http://pastebin.com/api.php <-- the apis are from there

+2  A: 

The request is not actually sent until you do wr.GetResponse();

See here, although the example is shameful in its failure to use using{}

Isaac Cambron