5

私はこのコードを持っています:

string downloadedString;
System.Net.WebClient client;

client = new System.Net.WebClient();

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

これはHWIDタイプのセキュリティです(プログラムの使用が許可されているかどうかを確認するためにHWIDをチェックします)

とにかく、一度に複数の行を配置できるようにしたいのです。例:

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

そして、各行を1つずつ読み取り、downloadedStringに更新することができます。

4

1 に答える 1

18

URLを文字列としてダウンロードするのではなく、ストリームとして読み取ってください。

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
    }
}
于 2012-05-31T01:15:11.600 に答える