Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ FTP
hi.
 
i try to use the ftp commands in c++.
Its throwing the error as 997.. "Overlapped I/O operation is in progress".
 
Code:
 
HINTERNET  hHandle = InternetOpen("s", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC);
	if( hHandle  != NULL )
	{
		printf("Success");
	}
	
	HINTERNET  hFtpSession = InternetConnect( hHandle, "172.16.11.33", INTERNET_DEFAULT_FTP_PORT, "XXXX", "12345", INTERNET_SERVICE_FTP, NULL, NULL);
	if( hFtpSession != NULL )
	{
		printf("\nSucces:");
	}
	else
	{
		printf("\nFailed %d", GetLastError());
	}
 
	FtpPutFile(hFtpSession, "C:\\1.txt", " mylog.txt", FTP_TRANSFER_TYPE_BINARY, 0);
	char chTemp[1024] = "";
	DWORD dw = sizeof(chTemp);
	
	if( FtpGetCurrentDirectory(hFtpSession, chTemp,&dw) == TRUE )
	{
		printf("\nSuccess");
	}
	else
	{
		printf("\nError::%d", GetLastError());
	}
Posted 21-Jan-13 3:13am
Edited 16-Sep-14 1:51am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You are using asynchronous mode (INTERNET_FLAG_ASYNC). In this case, all functions will return immediately without waiting for the requested action to be finished. The error 997 / ERROR_IO_PENDING indicates that such an action has not been finished yet.
 
With asynchronous operations, use the InternetSetStatusCallback[^] function to be notified when operations has been finished. See also the Asynchronous Example Application[^] in the MSDN.
  Permalink  
Comments
H.Brydon at 21-Jan-13 10:37am
   
Complete and correct ... +5
aimdharma at 22-Jan-13 1:22am
   
ftpcreateDirectory is giving error as 19...
but permission i provided. i can able to create from cmd line.
i used the FtpGetCurrentDirectory also. its giving the valid path
Jochen Arndt at 22-Jan-13 3:09am
   
This not really related to your initial question and my answer.
Error 19 is ERROR_WRITE_PROTECT and makes no sense here. What do you mean by cmd line? FtpCreateDirectory() creates a directory on the FTP server.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

HINTERNET hHandle = InternetOpen("s", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0)
 
Specify the last parameter to InternetOpen() as 0 and in FtpCreateDirectory() use forward slash("/") instead of back slash("\") as a path separator .
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 215
1 George Jonsson 175
2 Kornfeld Eliyahu Peter 159
3 PIEBALDconsult 110
4 Richard MacCutchan 85
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 16 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100