質問

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);
役に立ちましたか?

解決

を作成するだけです file あなたが望むパスを持つオブジェクトと QFtp そこを保存します。何かのようなもの;

file = new QFile(QString("/path/to/download/%1").arg(fileName));
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top