Page 228 - PDA Robotics Using Your Personal Digital Assistant to Control Your Robot
P. 228

PDA 10  5/27/03  8:51 AM  Page 204
                                  m_pFtpConnection = m_pInetSession->GetFtpConnection(strServerName, user,
                          password, 21 );            PDA Robotics
                               }
                               catch (CInternetException* pEx)
                               {
                                  // catch errors from WinINet
                                  TCHAR szErr[1024];
                                  if (pEx->GetErrorMessage(szErr, 1024))
                                    // AfxMessageBox(szErr, MB_OK);
                                    status_msg = szErr;
                                  else
                                    status_msg = szErr;
                                    //AfxMessageBox(IDS_EXCEPTION, MB_OK);
                                  pEx->Delete();
                                  m_pFtpConnection = NULL;
                                  return(FALSE);
                               }
                             }
                             else
                             {
                               status_msg = "Bad URL, please check host name";

                             }
                             BOOL rcode = m_pFtpConnection->SetCurrentDirectory(remote_path);
                             if( FALSE == rcode )
                             {
                               status_msg = "Could not goto directory specified. Please re enter";

                             }
                             CString strDirName;
                             rcode = m_pFtpConnection->GetCurrentDirectory(strDirName );

                             rcode = m_pFtpConnection->PutFile( filename, (LPCTSTR) remote_filename,
                                   FTP_TRANSFER_TYPE_BINARY, 1 );
                             if( FALSE == rcode )
                             {
                               status_msg = "Could not update file. Check settings";
                               return(FALSE);
                             }
                             return(TRUE);
                          }

                          // Test connection

                          BOOL CFtp::TestConnect(CString host, CString user, CString password, INTERNET_PORT
                          port, CString& status_msg)
                          {

                          204
   223   224   225   226   227   228   229   230   231   232   233