Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
HINTERNET  hHandle = InternetOpen("SapphireBackup", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_FROM_CACHE);
	if( hHandle  != NULL )
	{
		printf("Success");
	}
	
	HINTERNET  hFtpSession = InternetConnect( hHandle, "172.133.12.33", INTERNET_DEFAULT_FTP_PORT, "c:\\test11233", "12345", INTERNET_SERVICE_FTP, NULL, NULL);
	if( hFtpSession != NULL )
	{
		printf("\nSucces:");
	}
	else
	{
		printf("\nFailed %d", GetLastError());
	}

	HINTERNET  test;
	
	//FtpCommand(hFtpSession, TRUE, FTP_TRANSFER_TYPE_BINARY, "mkdir xyz123", 0, test);
	if( FtpSetCurrentDirectory(hFtpSession, "d:\\Backup") == TRUE )
	{
		printf("\nSuccess\n");
	}
	else
	{
		printf("\nFailed%d", GetLastError());
	}
	char chTemp[1024] = "";
	DWORD dwTest = 1024;
	if( FtpGetCurrentDirectory(hFtpSession, chTemp,&dwTest) == TRUE )
	{
		printf("\nSuccess %s", chTemp);
	}
	else
	{
		printf("\nError::%d", GetLastError());
	}

	

	if( FtpCreateDirectory(hFtpSession,  "dharmaraj1") == TRUE )
	{
		printf("\nSuccess");
	}
	else
	{
		printf("\nFailed %d", GetLastError());
		DWORD  dwInetError = 19, dwExtLength  = 1024;
		dwExtLength = 1024;
		memset(chTemp, 0, sizeof(chTemp));
		InternetGetLastResponseInfo(&dwInetError, chTemp, &dwExtLength);
		printf("were");
	}
Posted
Updated 22-Jan-13 1:18am
v2

1 solution

You are opening your connection with INTERNET_FLAG_FROM_CACHE:
MSDN Quote:
Does not make network requests. All entities are returned from the cache. If the requested item is not in the cache, a suitable error, such as ERROR_FILE_NOT_FOUND, is returned.

So write accesses like creating a FTP directory will of course fail.
 
Share this answer
 
Comments
@BangIndia 22-Jan-13 7:27am    
What will be the solution for that issue..
Jochen Arndt 22-Jan-13 7:31am    
Opening the internet connection in a state that uses real network requests of course. To do this, pass zero or INTERNET_FLAG_ASYNC for the dwFlags parameter.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900