Click here to Skip to main content
12,951,034 members (50,410 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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 2:13am
Updated 16-Sep-14 0: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 21-Jan-13 10:37am
   
Complete and correct ... +5
aimdharma 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 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
Top Experts
Last 24hrsThis month
OriginalGriff 6,084
CHill60 3,480
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,830


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 16 Sep 2014
Copyright © CodeProject, 1999-2017
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