有人可以告诉我使用 libcurlnet 下载给定 url 的文件的正确方法吗
FileStream fs = new FileStream("something.mp3", FileMode.Create);
WriteData wd = OnWriteData;
easy.SetOpt(CURLoption.CURLOPT_URL, downloadFileUrl);
easy.SetOpt(CURLoption.CURLOPT_WRITEDATA, wd);
if ("CURLE_OK" == easy.Perform().ToString())
{
//save_file
}
static System.Int32 OnWriteData(FileStream stream, byte[] buf, Int32 size, Int32 nmemb, Object extraData)
{
stream.Write(buf, 0, buf.Length);
return size * nmemb;
} //OnWriteData
public delegate System.Int32
WriteData(
FileStream stream, //added parameter
byte[] buf, Int32 size, Int32 nmemb, Object extraData);