Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialkenwrites
12,890 PointsProblem with "DownloadData" method of WebClient.
Can't figure out why my code's not passing muster with the C# Streams and Data Processing quiz. Complete code should be attached - let me know if it's not showing up for some reason. The relevant lines are:
using (var webClient = new WebClient())
{
byte[] treehouseBytes = webClient.DownloadData("https://www.teamtreehouse.com/");
}
This code gets the error:
Bummer: Did you pass the url "https://www.teamtreehouse.com" into the 'DownloadData' method?
Task 2 of "WebClient" quiz: https://teamtreehouse.com/library/c-streams-and-data-processing/streaming-data-on-the-net/webclient
using System;
using System.IO;
using System.Net;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(GetTreehouseHome());
}
public static string GetTreehouseHome()
{
string treehouse = "";
using(var webClient = new WebClient())
{
byte[] treehouseBytes = webClient.DownloadData("https://www.teamtreehouse.com/");
}
return treehouse;
}
}
}
2 Answers
KRIS NIKOLAISEN
54,972 PointsRemove the forward slash at the end so it is just "https://www.teamtreehouse.com"
kenwrites
12,890 PointsThank you! That was it.