1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
FileStream fs = new FileStream("myfile.bin", FileMode.Create, FileAccess.Write, FileShare.Write);
Easy easy = new Easy();
Easy.WriteFunction wf = new Easy.WriteFunction(OnWriteData);
easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf);
easy.SetOpt(CURLoption.CURLOPT_WRITEDATA, fs);
easy.SetOpt(CURLoption.CURLOPT_URL, "ftp://127.0.0.1:21/myfile.bin");
easy.SetOpt(CURLoption.CURLOPT_USERPWD, "anonymous:anonymous");
easy.SetOpt(CURLoption.CURLOPT_TIMEOUT, 36000);
easy.SetOpt(CURLoption.CURLOPT_TRANSFERTEXT, false);
easy.SetOpt(CURLoption.CURLOPT_UPLOAD, false);
CURLcode code = easy.Perform();
fs.Close();
easy.Cleanup();
...
public Int32 OnWriteData(Byte[] buf, Int32 size, Int32 nmemb, Object extraData)
{
FileStream fs = (FileStream)extraData;
fs.Write(buf, size * nmemb, nmemb);
return (size * nmemb);
} |
Partager