How to download webpage using asp.net and c# ?

Wednesday, July 8, 2009

See the following code,

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;

namespace DownloadingFile
{
class Program
{
static void Main(string[] args)
{
WebRequest reqFile = WebRequest.Create("http://www.codecollege.net/2009/07/cloud-computing.html");

WebResponse resFile = reqFile.GetResponse();

Stream smFile = resFile.GetResponseStream();
// Output the downloaded stream to the console
StreamReader sr = new StreamReader(smFile);
string line;
while ((line = sr.ReadLine()) != null)
Console.WriteLine(line);
Console.Read();
}
}
}
www.codecollege.NET

0 comments

Post a Comment

LinkWithin

Blog Widget by LinkWithin

Recommended Books