Wednesday, 28 August 2013

Inputting values to a string as a website URL for the page to be downloaded

Inputting values to a string as a website URL for the page to be downloaded

I'm messing around with the System.Net library in C# and I'm trying to
simply have it set up such that you enter an url and it will take that as
a string and put that into the parameter for the URl in the
Client.DownloadString() field.
Here is my code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
namespace StringDownloadTest
{
class GetInformation
{
string EnterString;
public string InputString()
{
EnterString = Console.ReadLine();
return EnterString;
}
}
class DownloadString
{
static void Main(string[] args)
{
GetInformation R = new GetInformation();
R.InputString();
string downloadedString;
System.Net.WebClient client;
client = new System.Net.WebClient();
downloadedString = client.DownloadString(R.InputString());
Console.WriteLine("String: {0}", downloadedString);
}
}
}
Any help here, it will compile but the program crashes.

No comments:

Post a Comment