Click here to Skip to main content
Rate this: bad
good
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
Edited 22-Jan-13 1:18am
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 at 22-Jan-13 7:27am
   
What will be the solution for that issue..
Jochen Arndt at 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
0 Sergey Alexandrovich Kryukov 398
1 CPallini 333
2 George Jonsson 270
3 OriginalGriff 159
4 Prasad Khandekar 135
0 OriginalGriff 4,613
1 CPallini 3,340
2 Sergey Alexandrovich Kryukov 2,771
3 George Jonsson 2,254
4 Gihan Liyanage 2,020


Advertise | Privacy | Mobile
Web01 | 2.8.140905.1 | Last Updated 22 Jan 2013
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