我可以将文件上传到ftp。但是如何删除文件
Qt版本:5.2.0
如何做deleteFile函数。
我可以将文件上传到ftp。但是我该如何删除文件 刚删除ftp上的任何文件我想,请帮忙。 Qnetworkaccessmanag将使用。
没有Qftp。
class Uploader: public QObject
{
Q_OBJECT
public:
Uploader(QObject *p = 0): QObject(p) { }
void fileupload(const QString &file) //OK NO PROBLEM
{
QFileInfo finfo(file);
QUrl url("ftp://www.website.com/"+finfo.fileName());
url.setUserName("username");
url.setPassword("pass");
data = new QFile(file, this);
if (data->open(QIODevice::ReadOnly)) {
reply = nam.put(QNetworkRequest(url), data);
connect(reply, SIGNAL(uploadProgress(qint64, qint64)), SLOT(uploadProgress(qint64, qint64)));
connect(reply, SIGNAL(finished()), SLOT(uploadDone()));
}
else
qDebug() << "Oops";
}
void deletefile(QUrl ftpUrl) ????????????
{
HOW CODE ????????
}
public slots:
void uploadProgress(qint64 bytesSent, qint64 bytesTotal) {
qDebug() << "Uploaded" << bytesSent << "of" << bytesTotal;
}
void uploadDone() {
qDebug() << "Finished" << reply->error();
data->deleteLater();
reply->deleteLater();
}
private:
QNetworkAccessManager nam;
QFile *data;
QNetworkReply *reply;
};