
{
// clean up any objects that are still lying around
if (m_pFtpConnection != NULL)
{
m_pFtpConnection->Close();
delete m_pFtpConnection;
}
if (m_pInetSession != NULL)
{
m_pInetSession->Close();
delete m_pInetSession;
}
}
// Update our file
BOOL CFtp::UpdateFtpFile(CString host, CString user, CString password, CString
remote_path, CString filename, CString remote_filename, CString& status_msg)
{
CString strFtpSite;
CString strSer verName;
CString strObject;
INTERNET_PORT nPor t;
DWORD dwSer viceType;
if (!AfxParseURL(ftp_host, dwServiceType, strSer verName, strObject, nPort))
{
// tr y adding the "ftp://" protocol
CString strFtpURL = _T("ftp://");
strFtpURL += host;
if (!AfxParseURL(strFtpURL, dwServiceType, strSer verName, strObject, nPort))
{
// AfxMessageBox(IDS_INVALID_URL, MB_OK);
// m_FtpTreeCtl.PopulateTree();
status_msg = "Bad URL, please check host name";
return(FALSE);
}
}
// If the user has provided all the information in the
// host line then dwServiceType, strServerName, strObject, nPor t will
// be filled in.. but since I've provided edit boxes for each we will use these.
// Now open an FTP connection to the ser ver
if ((dwSer viceType == INTERNET_SERVICE_FTP) && !strServerName.IsEmpty())
{
try
{
Chapter 10 / The PDA Robotics Command Center
203
PDA 10 5/27/03 8:51 AM Page 203