I want download file http://img1.ak.crunchyroll.com/i/croll_manga/e/257692e8c297b8907e2607964454b941_1438752352_main to string.
In C++ I writed function
string opener(string url)
{
CURL *curl;
CURLcode res;
std::string readBuffer;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return readBuffer;
}
This work properly.
In C# I writed this class
namespace Crmrip
{
class opener
{
public static string open(string url)
{
using (WebClient page = new WebClient())
{
try
{
page.Encoding = Encoding.UTF8;
page.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0";
string result = page.DownloadString(url);
return result;
}
catch (WebException er)
{
MessageBox.Show(er.ToString());
return null;
}
}
}
}
}
This class work not properly. Downloaded file is too big. File downloaded in C++ have 487 778 bytes and is OK. File downloaded in C# have 879 910 and is too big.
Why file downloaded in C# is too big ?