Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++CFTP
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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 695
1 OriginalGriff 518
2 Abhinav S 313
3 thatraja 245
4 CPallini 130
0 Sergey Alexandrovich Kryukov 8,372
1 OriginalGriff 4,830
2 Peter Leow 3,784
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid