Click here to Skip to main content
12,455,517 members (64,819 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C++ C FTP
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 21-Jan-13 23:32pm
Updated 22-Jan-13 1:18am
Jochen Arndt140.2K
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
aimdharma 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2016
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