libcurl (.net) with C# :

I determined that 9 out of 10 times downloading my various pdf files will work. The problem is the 1 of 10 times where the pdf returned was 22kb (and corrupt) instead of a working pdf of size 40kb...

Please let me know if there is an alternate way I can write my pdf out.. I've spent so much time and I'm at the end of the ropes.. Any help would be appreciated! Below is the key code areas..

// Code to Download the pdf

   try
                {
                    easy.SetOpt(CURLoption.CURLOPT_URL, linkToPDF); //
   prep for downloading the PDF
                    Easy.WriteFunction wfile = new
   Easy.WriteFunction(OnWriteFile); //attach method for writing to a file
                    easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wfile);

   _binaryWriter = new BinaryWriter(File.Open(savePath, FileMode.Append));_
   _easy.Perform(); // download PDF_
                    binaryWriter.Close(); //close file
                }
                catch (Exception e)
                {
                    return results =
   PageParseResults.FileDownloadedOrSavedNotSuccessful;
                }

                easy.Cleanup();
                Curl.GlobalCleanup();

// Writing to File.. (Potential Problem Area)


   public Int32 OnWriteFile(Byte[] buf, Int32 size, Int32 nmemb, Object
   extraData)
   {

          binaryWriter.Write(buf, 0, nmemb);

                return size * nmemb;
   }



-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to