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);
1 ответ
Решение
Просто создайте file
объект с нужным вам путем и QFtp
сохраню там. Что-то вроде;
file = new QFile(QString("/path/to/download/%1").arg(fileName));