CFtpConnection::PutFile()的问题

codecola 2010-07-16 02:49:14
程序中调用CFtpConnection::PutFile()大部分情况都是成功的。
CFtpConnection::PutFile()返回0表示错误,而我发现有时不返回0,却没有上传成功。
而且不应该是权限或文件忙的问题:
如果没有向服务器写文件的权限,会出错,返回的也是0。
如果服务器的文件正忙,也会出错,返回的也是0。
有人遇到过这种问题吗?

服务器是ReadHat Enterprise Linux 5自带的vsftp。


MSDN中是这么描述的:

MFC Library Reference
CFtpConnection::PutFile

Call this member function to store a file on an FTP server.
Copy

BOOL PutFile(
LPCTSTR pstrLocalFile,
LPCTSTR pstrRemoteFile,
DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY,
DWORD_PTR dwContext = 1
);

Parameters

pstrLocalFile

A pointer to a string containing the name of the file to send from the local system.

pstrRemoteFile

A pointer to a string containing the name of the file to create on the FTP server.

dwFlags

Specifies the conditions under which the transfer of the file occurs. Can be any of the FTP_TRANSFER_* constants described in OpenFile.

dwContext

The context identifier for placing the file. See Remarks for more information about dwContext.

Return Value

Nonzero if successful; otherwise 0. If the call fails, the Win32 function GetLastError may be called to determine the cause of the error.
Remarks

PutFile is a high-level routine that handles all of the operations associated with storing a file on an FTP server. Applications that only send data, or that require closer control over the file transfer, should use OpenFile and CInternetFile::Write.

Override the dwContext default to set the context identifier to a value of your choosing. The context identifier is associated with this specific operation of the CFtpConnection object created by its CInternetSession object. The value is returned to CInternetSession::OnStatusCallback to provide status on the operation with which it is identified. See the article Internet First Steps: WinInet for more information about the context identifier.
Requirements

Header: afxinet.h
...全文
485 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
codecola 2010-07-23
  • 打赏
  • 举报
回复
我每次要更新几十台服务器,偶尔会出现有个别主机的文件没有更新,但也没有报错!
奇怪!
codecola 2010-07-20
  • 打赏
  • 举报
回复
顶起来!!!
codecola 2010-07-16
  • 打赏
  • 举报
回复
与vsftp有关系吗?

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧