Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrapper the CURLOPT_WRITEDATA #5

Open
chucklu opened this issue Jul 22, 2016 · 4 comments
Open

wrapper the CURLOPT_WRITEDATA #5

chucklu opened this issue Jul 22, 2016 · 4 comments

Comments

@chucklu
Copy link

chucklu commented Jul 22, 2016

http://stackoverflow.com/questions/1636333/download-file-using-libcurl-in-c-c
in this example
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
fp is a File* pointer

@chucklu
Copy link
Author

chucklu commented Jul 22, 2016

CURLOPT_WRITEDATA
Object reference to pass to the Easy.WriteFunction delegate. Note that if you specify the CURLOPT_WRITEFUNCTION, this is the object you'll get as input.

if you can implement pass a file pointer,and the libcurl will write the data to the file automatically

@pjquirk
Copy link
Owner

pjquirk commented Jul 22, 2016

Sorry, I don't understand what issue you're raising with this library. Can you clarify?

@chucklu
Copy link
Author

chucklu commented Jul 25, 2016

CurlSharp\Samples\EasyGet\EasyGet.cs
Curl.GlobalInit(CurlInitFlag.All);

            using (var easy = new CurlEasy())
            {
                easy.Url = args.Count() > 1 ? args[0] : "http://www.amazon.com/";
                easy.WriteData = null;
                easy.WriteFunction = OnWriteData;
                //easy.ProgressFunction = OnProgressData;
                easy.Perform();
            }

            Curl.GlobalCleanup();

@chucklu
Copy link
Author

chucklu commented Jul 25, 2016

easy.WriteData = null;
the WriteData property of easy,I want to set this as file pointer

I have tried this,
//string fileName = "test.txt";
//TextWriter textWriter = File.CreateText(fileName);
//curlEasy.WriteData = textWriter;

System.ArgumentException was unhandled
HResult=-2147024809
Message=Object contains non-primitive or non-blittable data.
Source=mscorlib
StackTrace:
at System.Runtime.InteropServices.GCHandle.InternalAlloc(Object value, GCHandleType type)
at System.Runtime.InteropServices.GCHandle.Alloc(Object value, GCHandleType type)
at CurlSharp.CurlEasy.getHandle(Object obj) in D:\SourceCode\GitHub\CurlSharp\CurlSharp\CurlEasy.cs:line 1541
at CurlSharp.CurlEasy.setWriteData(Object data) in D:\SourceCode\GitHub\CurlSharp\CurlSharp\CurlEasy.cs:line 234
at CurlSharp.CurlEasy.set_WriteData(Object value) in D:\SourceCode\GitHub\CurlSharp\CurlSharp\CurlEasy.cs:line 217
at LibCurlTest.Form1.button1_Click(Object sender, EventArgs e) in F:\CodeForGitBlit\LibCurl\LibCurlTest\Form1.cs:line 37
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at LibCurlTest.Program.Main() in F:\CodeForGitBlit\LibCurl\LibCurlTest\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants