Tom Hanson
Tom Hanson

Reputation: 945

Fastest Way To Download Website Data C#

I am writing an Rcon in Visual Studio for Black Ops. I know its an old game but I still have a server running.

I am trying to download the data from this link

Black Ops Log File

I am using this code.

System.Net.WebClient wc = new System.Net.WebClient();
string raw = wc.DownloadString(logFile);

Which take between 6441ms to 13741ms according to Visual Studio.

Another attempt was...

string html = null;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(logFile);
request.AutomaticDecompression = DecompressionMethods.GZip;
request.Proxy = null;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
    html = reader.ReadToEnd();
}

Which also takes around 6133ms according to VS debugging. I have seen other rcon respond to commands really quickly. Mine take on best 5000ms which is not really acceptable. How can I download this this information quicker. I am told it shouldn't take this long??? What am I doing wrong?

Upvotes: 2

Views: 622

Answers (1)

usr
usr

Reputation: 171236

This is just how long the server takes to answer:

enter image description here

In the future you can debug such problems yourself using network tools such as Fiddler or by profiling your code to see what takes the longest amount of time.

Upvotes: 1

Related Questions