English 中文(简体)
转让校准后更正的本安卷宗
原标题:Corrupted Binary Files after Transfer libcurl

我正在利用校准将向FTP移交双亲档案(exe),并将它保存到当地档案中。 问题在于,在移交档案后,该档案被更改,不再成为有效的Win32申请,并且不再有效。 这里我怎么做:

CURL *curl;

curl = curl_easy_init();
    FILE* f = fopen("C:\blah.exe", "w");

if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.mysite.com");
    curl_easy_setopt(curl, CURLOPT_USERPWD, "blah:blah");
    curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_SINGLECWD);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &f);
} else {
            fclose(f);
    return CURL_EASY_INIT_FAIL;
}

    fclose(f);

档案是书面的,但比在FTP服务器上更大。 和我一样,试图管理这一错误会导致“%1不是有效的Win32应用”。 我是否忘记了制定一种选择或某种选择?

最佳回答

You forgot the binary flag. This is the correct code:

 FILE* f = fopen("C:\blah.exe", "wb");
问题回答

原因是,你转作ASCII,而不是双手。 因此,您的行文可能破裂。 在双亲中,有的CRs可能变成CR LF,或者相反。 Tune CURL进行双向转让。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签