首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >QFtp下载位置问题

QFtp下载位置问题
EN

Stack Overflow用户
提问于 2011-01-03 18:24:04
回答 1查看 889关注 0票数 0

我刚刚用Qt写了一个小的ftp客户端。问题是当我下载时,ftp->get()命令会将文件下载到默认位置。我想定义一个下载文件的路径。

这是我的DownloadFile方法:

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-01-03 18:27:34

只需创建包含所需路径的file对象,QFtp就会保存在该对象中。就像这样;

代码语言:javascript
复制
file = new QFile(QString("/path/to/download/%1").arg(fileName));
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4583668

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档