Is there a way to read from a website, one line at a time?

I have this code:

string downloadedString;
System.Net.WebClient client;

client = new System.Net.WebClient();

downloadedString = client.DownloadString(
     "http://thebnet.x10.mx/HWID/BaseHWID/AlloweHwids.txt");

This is an HWID type security (it will check your HWID to see if you are allowed to use the program)

In any case, I want me to be able to put several lines at the same time, for example:

xjh94jsl <-- Not a real HWID
t92jfgds <-- Also not real

And you can read each line one by one and update it to the loadable line.

+5
source share
1 answer

Do not load url as a string, read it as a stream.

using System.IO;
using System.Net;

var url ="http://thebnet.x10.mx/HWID/BaseHWID/AlloweHwids.txt";
var client = new WebClient();
using (var stream = client.OpenRead(url))
using (var reader = new StreamReader(stream))
{
    string line;
    while ((line = reader.ReadLine()) != null)
    {
        // do stuff
    }
}
+18
source

All Articles