VC FTPサービスとクライアント
3210 ワード
1 FTPサービスhttp://www.codeproject.com/KB/IP/ftpserver.aspx
ルートディレクトリの設定がなく、しばらく見つかりませんでしたが、後で自分が必要なら追加します.
CFTPServer
This class is in fact the FTP server, and controls all other classes needed for the server to work. Although
2 FTPクライアントhttp://www.codeproject.com/KB/IP/ftpclientclass.aspx
見ていたらディレクトリ関連の操作がなかったのがちょっと残念
相変わらずいいものだ
ルートディレクトリの設定がなく、しばらく見つかりませんでしたが、後で自分が必要なら追加します.
CFTPServer
This class is in fact the FTP server, and controls all other classes needed for the server to work. Although
CFTPServer
is part of a dialog based application, it does not rely on a User Interface and can easily be implemented in a service or console application as well.BOOL Start()
Activates the FTP server. It opens a listening socket (port 21) to accept connections. void Stop()
Deactivates the server and disconnects all connected clients by terminating the running threads. BOOL IsActive()
Is FTP server active? void SetMaxUsers(int nValue)
Set maximum number of users. void SetPort(int nValue)
Set listening port for new connections. void SetTimeout(int nValue)
Set connection timeout (in ms). When a client does not send any commands for nValue
ms, the server will close the connection. void SetWelcomeMessage(LPCTSTR lpszText)
Set the text that will be displayed when the client logs on. void Initialize(CFTPEventSink *pEventSink)
Set the event sink. The event sink will be the window (or any class) that receives the events generated by the FTP server. See CFTPEventSink
description for more info. 2 FTPクライアントhttp://www.codeproject.com/KB/IP/ftpclientclass.aspx
見ていたらディレクトリ関連の操作がなかったのがちょっと残念
nsFTP::CFTPClient ftpClient;
nsFTP::CLogonInfo logonInfo("localhost", 21, "anonymous", "[email protected]");
// connect to server
ftpClient.Login(logonInfo);
// get directory listing
nsFTP::TSpFTPFileStatusVector list;
ftpClient.List("/", list);
// iterate listing
for( nsFTP::TSpFTPFileStatusVector::iterator it=list.begin();
it!=list.end(); ++it )
TRACE("/n%s", (*it)->Name().c_str());
// do file operations
ftpClient.DownloadFile("/pub/test.txt", "c://temp//test.txt");
ftpClient.UploadFile("c://temp//test.txt", "/upload/test.txt");
ftpClient.RenameFile("/upload/test.txt", "/upload/NewName.txt");
ftpClient.Delete("/upload/NewName.txt");
// disconnect
ftpClient.Logout();
相変わらずいいものだ