Pastebin c#自动上传

时间:2010-05-17 23:09:53

标签: c# pastebin

我需要我的应用程序将输出上传到pastebin但我无法让它工作 这是代码

        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< - api来自那里

1 个答案:

答案 0 :(得分:5)

在您执行wr.GetResponse();

之前,实际上并未发送请求

请参阅here,尽管该示例因未能使用using{}而感到羞耻