Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading Web Pages

Status
Not open for further replies.

Kavius

Programmer
Apr 11, 2002
322
CA
How can I allow my application to open a text document via HTTP?

I had an old C app for this, but the format has changed and I no longer have the code for this module of the system. Figured I would rewrite in C#.
 
As for cmdematos post you can use the WebRequest and WebResponse classes in the System.Net namespace to retrieve a file by Http.
Code:
WebRequest request = WebRequest.Create("[URL unfurl="true"]http://www.domain.com/textfile.txt");[/URL]
WebResponse response = request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
This can allbe done Asynchrously as well using the BeginGetResponse method and an AsyncCallback delegate to handle the callback.

Rob

Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed - Eisenhower 1953
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top