1

This is what I have so far. Fairly new myself. Would much appreciate the help. I am aiming to save the info into a text file created pretty much anywhere, but preferably inside temp folder or something.

    static async void GetNewData()
    {
        String page = "http://www.coinmarketcap.com";
        var client = new HttpClient();

        // Create the HttpContent for the form to be posted.
        var requestContent = new FormUrlEncodedContent(new[] {
        new KeyValuePair<string, string>("text", "This is a block of text"),
});

        // Get the response.
        HttpResponseMessage response = await client.PostAsync(page,
            requestContent);

        // Get the response content.
        HttpContent responseContent = response.Content;

        // Get the stream of the content.
        using (var reader = new StreamReader(await responseContent.ReadAsStreamAsync()))
        {
            // Write the output.
            Console.WriteLine(await reader.ReadToEndAsync());

            using (StreamWriter w = File.AppendText(reader.ReadToEndAsync().ToString);

    //        StreamWriter sw1 = new StreamWriter(File.OpenWrite());
    //     sw1.Write(await reader.ReadToEndAsync() textytext);
        }
    }



}
}

Once again, any advice would be extremely helpful, and I will be sure to upvote the most accurate answer :)

  • using (StreamWriter w = File.AppendText(reader.ReadToEndAsync().ToString); It sais this cant be converted to string – ceruleanblue May 30 '18 at 03:04
  • 1
    http://codesnippets.fesslersoft.de/copy-one-stream-to-another/ and https://stackoverflow.com/questions/230128/how-do-i-copy-the-contents-of-one-stream-to-another and https://msdn.microsoft.com/en-us/library/dd782932(v=vs.110).aspx – Chetan May 30 '18 at 03:24

0 Answers0