PutData to create empty file (General questions)

by Oleg @, (6474 days ago)

Hi,
I am trying to use PutData to create empty file on FTP server.
Code is like this (VC++):

VARIANT var;
var.vt = VT_BSTR;
var.bstrVal = SysAllocString(_T( /test.txt ));
SFtp->PutData(_T( ), var);

But COleDispatchException occured.
What I am doing wrong?

locked

Re: PutData to create empty file

by Jasmine, (6474 days ago) @ Oleg

Oleg,

that exception should contain some message or error number. Can you tell me what it is?

Kreso

locked

Re: PutData to create empty file

by Oleg @, (6474 days ago) @ Jasmine

I get message:

Unhandled exception at 0x7675b09e in Appname.exe: Microsoft C++ exception: COleDispatchException at memory location 0x02d0dc28..

locked

Re: PutData to create empty file

by Jasmine, (6474 days ago) @ Oleg

Oleg,

are you sure that

SFtp->PutData(_T( ), var);

first argument is also BSTR? This looks to me like invalid argument issue, which in C++ gives you results like you experienced it..

Kreso

locked

Re: PutData to create empty file

by Oleg @, (6474 days ago) @ Jasmine

Solved it.
Error was that I put SetBlocking(TRUE) before CreateDispatch.
After fixing exception disappeared.
And replace
var.bstrVal = SysAllocString(_T( /test.txt ))
with
var.bstrVal = _T( /test.txt )
It work
Thank you

locked