0

Qtを使用して小さなftpクライアントを作成しました。問題は、ダウンロード時に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);
4

1 に答える 1

1

file必要なパスでオブジェクトを作成するだけで、QFtpそこに保存されます。何かのようなもの;

file = new QFile(QString("/path/to/download/%1").arg(fileName));
于 2011-01-03T10:27:34.470 に答える