⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0503007.htm

📁 VC知识库5_chm_decompile_20040520_210715
💻 HTM
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
<link rel="stylesheet" type="text/css" href="../../vckbase.css">
</head>

<body>

<div align="justify">
  <table border="0" width="100%" class="font" height="57">
    <tr>
      <td width="27%" height="6" class="bigfont" bgcolor="#B8CFE7" align="center" bordercolor="#800080">
      <font color="#800080">VC知识库(五)</font>
      </td>
      <td width="73%" height="6" class="bigfont" bgcolor="#B8CFE7" align="center" bordercolor="#800080">
      <font color="#800080">www.vckbase.com</font>
      </td>
    </tr>
    <tr>
      <td width="100%" height="4" class="header" valign="top" align="center" colspan="2">
      <hr>
      </td>
    </tr>
    <tr>
      <td width="100%" height="17" class="header" valign="top" align="center" colspan="2">
      <big>使用MFC编写FTP程序</big>
      </td>
    </tr>
    <tr>
      <td width="100%" height="17" class="info" align="center" colspan="2">
      <big>闻怡洋</big>
      </td>  
    </tr>  
    <tr> 
      <td width="100%" height="22" class="font" colspan="2">
        <hr>
      </td>  
    </tr> 
    <tr> 
      <td width="100%" height="5" class="font" colspan="2"> 



<p>1、生成CInternetSession变量。</p>



<p>CInternetSession ses;</p> 
 
 
 
<p>2、打开FTP连接。</p> 
 
 
 
<p>CFtpConnection* pFTP=ses.GetFtpConnection(<a href="ftp://ftp.microsoft.com">&quot;ftp.microsoft.com&quot;</a>,&quot;user&quot;,&quot;password&quot;,port,FALSE);</p> 
 
 
 
<p>3、打开文件。</p> 
 
<span class="op"> 
 
 
 
<p>CInternetFile* pF=pFTP-&gt;OpenFile(&quot;abc.exe&quot;);</span></p> 
 
 
 
<p><span class="op">更简单的是使用</span></p> 
 
 
 
<p><span class="op">CFtpConnect::GetFile(...) ; CFtpConnection::PutFile(...) ;可以拷贝文件。</span></p> 
 
 
 
<p><span class="op">4、读取文件,由于CInternetFile是CStdFile的派生类,因此可以使用CFile,CStdFile的所有函数。</span></p> 
 
 
 
<p><span class="op">pF-&gt;Read(...)</span></p> 
 
 
 
<p>高级用法:</p> 
 
 
 
<p>1、查找文件,列文件目录。(<a href="mk:@ivt:vcsample/FA/D10/S695D.HTM">FTP  
 
Tree Sample in VC5</a>)</p> 
 
 
 
<p>CFTPFileFind类可以帮助你列出当前目录下的所有文件。用法和CFileFind相同。</p> 
 
 
 
<p>2、断点续传。</p> 
 
 
 
<p>当打开文件后,可以使用CInternetFile::Seek(...)重定位指针。但如果该服务器不支持断点续传会产生异常,应该有相应的捕捉代码。</p> 
 
 
 
<p>其它:</p> 
 
 
 
<p>同样的CHttpConnection的用法也很类似。</p> 
 
      </td>     
    </tr>    
    <tr> 
      <td width="100%" height="12" class="font" colspan="2">  
      </td>     
    </tr> 
    <tr> 
      <td width="100%" height="6" class="font" colspan="2">  
      </td>     
    </tr> 
    <tr> 
      <td width="100%" height="8" class="font" colspan="2">  
      </td>     
    </tr> 
    <tr>    
      <td width="100%" height="17" class="font" colspan="2"></td>     
    </tr>    
  </table>     
</div>     
     
</body>     
     
</html>     

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -