//注意:删除文件夹的时候 需要切换到当前文件夹之后,
//获取当前文件夹的父目录,然后再删除,否则找不到文件夹
void ChangeAndDeleteDir()
{
sf::IpAddress address = "127.0.0.1";
sf::Ftp server;
sf::Ftp::Response connectResponse = server.connect(address);
if (!connectResponse.isOk())
{
//连接失败
}
// Ask for user name and password
std::string user = "test", password = "1234";
// Login to the server
sf::Ftp::Response loginResponse = server.login(user, password);
if (!loginResponse.isOk())
{
//登录失败
}
//获取当前工作的文件夹
sf::Ftp::DirectoryResponse workdir = server.getWorkingDirectory();
//切换工作的文件夹
sf::Ftp::Response response = server.changeDirectory("files");
if (!response.isOk())
{
//切换工作的文件夹失败
int yy = 55;
}
workdir = server.getWorkingDirectory();
//获取当前父文件夹
sf::Ftp::Response parentDir = server.parentDirectory();
workdir = server.getWorkingDirectory();
//注意:删除文件夹的时候 需要切换到当前文件夹之后,
//获取当前文件夹的父目录,然后再删除,否则找不到文件夹
response = server.deleteDirectory("files");
if (!response.isOk())
{
//删除失败
int yy = 55;
}
response = server.getWorkingDirectory();
server.disconnect();
}