simple question: I have an file online (txt). How to read it and check if its there? (C#.net 2.0)
This is too much easier:
using System.Net;
using System.IO;
...
using (WebClient client = new WebClient()) {
//... client.options
Stream stream = client.OpenRead("http://.........");
using (StreamReader reader = new StreamReader(stream)) {
string content = reader.ReadToEnd();
}
}
"WebClient" and "StreamReader" are disposables. The content of file will be into "content" var.
The client var contains several configuration options.
The default configuration could be called as:
string content = new WebClient().DownloadString("http://.........");