ftp一些操作函数.

1.连接服务器:

try
   {
    m_ftpConnect=new CFtpConnection(((CMyApp *)::AfxGetApp())->
                      m_pInetSession,m_applicationName,m_username,m_password,m_port);
    ((CStatic *)GetDlgItem(IDC_MANUALDLG_WAITING_STATIC))->ShowWindow(SW_HIDE);
    if (m_ftpConnect != NULL)
    {
     
     CString m_i;
     m_i=_T("connect success/r/n");
     m_ftpInfo +=m_i;
     UpdateData(FALSE);
     //m_inetSession.CloseFtpConnect();
     m_ftpConnect->Close();
     delete m_ftpConnect;
     AfxMessageBox(m_ftpInfo);
     OnOK();
    }
   }
   catch (CInternetException * pEx)
   {
    ((CStatic *)GetDlgItem(IDC_MANUALDLG_WAITING_STATIC))->ShowWindow(SW_HIDE);
    CString m_i;
    m_i=_T("connect failure/r/n");
    m_ftpInfo +=m_i;
    UpdateData(FALSE);
    TCHAR szError[1024];
    if ( pEx->GetErrorMessage(szError,1024))
    {
     m_i=(CString) szError;
     m_ftpInfo +=m_i;
     UpdateData(FALSE);
     AfxMessageBox(m_ftpInfo);
     
    }
    else
     AfxMessageBox(_T("There was an exception"));
     pEx->Delete();
   }
    }
  2.CFtpFileFind

CFtpFileFind ftpFileFind(m_pFtpConnection);
 //BOOL   bWorking=ftpFileFind.FindFile(m_strCurrentDirectory);
 //BOOL   bWorking=ftpFileFind.FindFile(m_strCurrentDirectory,INTERNET_FLAG_RELOAD|INTERNET_FLAG_EXISTING_CONNECT);
 BOOL   bWorking=ftpFileFind.FindFile(_T("*"));
 while(bWorking)
 { 
  
  bWorking=ftpFileFind.FindNextFile();//注意这句一定要放前面,否则在后面ftpFileFind调用任何函数都错误
  //::AfxMessageBox();
  if(ftpFileFind.IsDirectory())
  {
   //if(ftpFileFind.GetFileName()==
  }
  /*if(bWorking)
  {
   bCreateDirectory=TRUE;
  }*/
 }
 ftpFileFind.Close();

3.CFtpFileFind的两个函数的区别(IsDirectory() / IsDots())

//if(finder.IsDirectory()   &&   !finder.IsDots())   //如果是目录  
  IsDirectory判断是否为目录  
  IsDots判断是否为点或者点点--这个要说明一下,你用过Dos的话,就应该知道,每个目录下都有缺省的两个目录,名称分别为'.'和'..',分别代表上一层目录和本层目录。因此,当我们在遍历目录下文件时,需要过滤掉这两个缺省目录。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值