Can anyone tell me how to read a text file or a picture on the internet? For example, I want to compare the data in a string called "data", with a text file, for example, located at http://www.textfiles.com/text.txt. How would I go about downloading the text file into a string? I can do this locally with a file on my computer using:
Code:
string user="C:\stuff\text.txt";
string tmp="";
using (FileStream fs = File.Open(user, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
byte[] b = new byte[1024];
UTF8Encoding temp = new UTF8Encoding(true);
while (fs.Read(b, 0, b.Length) > 0)
{
tmp += (temp.GetString(b));
}
}
Like I said, this works for local files, so how can I modify this to read the file online instead?
Thanks