Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Change Current Remote FTP DirectoryC++ sample code to change the current remote directory on an FTP server during an FTP session. Downloads: MS Windows Visual C/C++ Libraries Linux/CentOS C/C++ Libraries MAC OS X C/C++ Libraries Solaris C/C++ Libraries C++ Builder Libraries FreeBSD C++ Libraries HP-UX C++ Libraries BlackBerry QNX C++ Libraries void FtpChangeRemoteDir(void)
{
CkFtp2 ftp;
ftp.UnlockComponent("anything for 30-day trial");
ftp.put_Hostname("ftp.chilkatsoft.com");
ftp.put_Username("***");
ftp.put_Password("***");
// non-passive (active) connections are most likely to work if firewalls are present.
ftp.put_Passive(false);
// Connect to the FTP server and login.
bool success = ftp.Connect();
if (!success)
{
ftp.SaveLastError("ftpLog.txt");
return;
}
// Change to a sub-directory relative to our current remote directory.
success = ftp.ChangeRemoteDir("download");
if (!success)
{
ftp.SaveLastError("ftpLog.txt");
return;
}
// Change to a directory that is an absolute path from our FTP login's home directory.
success = ftp.ChangeRemoteDir("/download");
if (!success)
{
ftp.SaveLastError("ftpLog.txt");
return;
}
// Move up one directory relative to our current remote directory.
success = ftp.ChangeRemoteDir("..");
if (!success)
{
ftp.SaveLastError("ftpLog.txt");
return;
}
// Change the current remote directory to the FTP account's home directory
success = ftp.ChangeRemoteDir("/");
if (!success)
{
ftp.SaveLastError("ftpLog.txt");
return;
}
// Go two directories down from the current remote directory.
success = ftp.ChangeRemoteDir("test/images");
if (!success)
{
ftp.SaveLastError("ftpLog.txt");
return;
}
ftp.Disconnect();
}
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.