QFTP Загрузить выпуск местоположения
Вопрос
Я только что написал крошечный клиент FTP с помощью QT. Проблема в том, когда я загружаю, ftp->get()
Команда загружает файл в местоположение по умолчанию. Я хотел бы определить путь, по которому пойдет загруженный файл.
Это мое DownloadFile
Метод:
QString fileName = fileListTreeWidget->currentItem()->text(0);
if (QFile::exists(fileName)) {
QMessageBox::information(this, tr("FTP"),
tr("There already exists a file called %1 in "
"the current directory.").arg(fileName));
return;
}
file = new QFile(fileName);
if (!file->open(QIODevice::WriteOnly)) {
QMessageBox::information(this, tr("FTP"),
tr("Unable to save the file %1: %2.")
.arg(fileName).arg(file->errorString()));
delete file;
return;
}
ftp->get(fileListTreeWidget->currentItem()->text(0), file);
Решение
Просто создайте file
возразить с тем, что вы хотите, и QFtp
спасет там. Что-то типа;
file = new QFile(QString("/path/to/download/%1").arg(fileName));
Не связан с StackOverflow