pConnect->SetCurrentDirectory( "C:\\FilesToSendToServer" ); //Need this set on client, i believe currently setting on server.
CFtpFileFind finder(pConnect);
finder.FindFile( "*", INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_EXISTING_CONNECT );
finder.FindNextFile();
CString filename = finder.GetFileName(); //finds the only file in that directory - test.txt
pConnect->PutFile( filename, "C:\\FilesReceived\\FILE_SENT_FROM_CLIENT.txt", FTP_TRANSFER_TYPE_BINARY, 1 )) //filename set to test.txt correctly
On the client I have the directory FilesToSendToServer with one test file – “test.txt”
I also have the working directory of this application on the client – C\uploadApp\
The code above sets the current directory correctly and “finds” the test file.
However, when PutFile executes with the filename parameter set correctly (test.txt) the functin returns the error file not found.
So as a test, I put a copy of test.txt in the applications working directory uploadApp and it DID send the file to the server.
Why does the file need to be in the working directory to be sent if the active directory is set in the CFtpConnection object?
(Does this mean for any file I want to send from the client I have to copy it over to the directory of the application?)
Thank You.
EDIT
Looks like SetCurrentDirectory calls FtpSetCurrentDirectory which
determine the remote site’s current working directory
So for a GET this would make sense…is there an alternate function for a PUT – to set the active directory of the local machine? (FYI – Unable to make a distinction between the remote directory on the server testing on same machine…if testing on target the SetCurrentDirectory should fail, as it is looking on the server…I assume)
It looks like you were meaning to call the win32 API SetCurrentDirectory. This will change the local directory instead of the remote directory that pConnect->SetCurrentDirectory changes. Try ::SetCurrentDirectory if you’re in a namespace. Of course your working directory will no longer be C:\uploadApp…