I would create a Win32 Console app with MFC Enabled.
I believe, however, Windows 7 comes with .NET installed.
Since you are doing this on Windows boxes, MFC is still an option.
I set the character set to be MultiByte and Ignored Library: MSVCRT.lib
This will compile under warning level 4
#include "stdafx.h"
#include <afxinet.h>
#include "SendToDestDani.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
CWinApp theApp;
bool SendToDest(char* pstrSourceFileName,
char* pstrDestFileName, char* pstrIpAddress, char* pstrUser,
char* pstrPassword, char* pstrWorkDir)
{
//Connect, transfer, disconnect.
afxCurrentAppName = "SendToDestMfc";
CInternetSession* pSess = new CInternetSession();
CFtpConnection* pFtp = NULL;
bool blnRetVal = true;
//Create the connection
pFtp=pSess->GetFtpConnection(pstrIpAddress,
pstrUser,pstrPassword, 21);
if(!pFtp->SetCurrentDirectory(pstrWorkDir))
{
blnRetVal = false;
}
if((TRUE == blnRetVal) && (!pFtp->PutFile(pstrSourceFileName,
pstrDestFileName, FTP_TRANSFER_TYPE_BINARY)))
{
blnRetVal=false;
}
//Close the connections
pFtp->Close();
pSess->Close();
//
delete pFtp;
delete pSess;
return blnRetVal;
}
void main(void)
{
HMODULE hModule = ::GetModuleHandle(NULL);
if (hModule != NULL)
{
// initialize MFC and print and error on failure
if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
return;
}
}
SendToDest("c:\\science\\xrdr.txt", "xrdr.txt", "10.1.11.11", "anonymous", "this@that.com", "/MPC_FILES");
} thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402