QT 5.8 - how to get DIR list from FTP Server
-
Hello,
I am using QT 5.8, and I can download single file from ftp server using with help of following classes
QNetworkAccessManager, QNetworkRequest and QUrl.All this works OK, if I know which file i want to download.
I am interested in getting dir list (e.g. *.txt) from ftp server.
How to do that? Any help is really appreciated.Thanks in advance.
DM. -
Hi, friend, welcome devnet.
if the Qt version less than 5.0 maybe the
QFtp
. will help you.But,
QFtp
has been removed from Qt. more than 5.0.I think, the Github Qt Ftp, Can help. Use It maybe easy.
//...... int setProxy(const QString &host, quint16 port); int connectToHost(const QString &host, quint16 port=21); int login(const QString &user = QString(), const QString &password = QString()); int close(); int setTransferMode(TransferMode mode); int list(const QString &dir = QString()); int cd(const QString &dir); int get(const QString &file, QIODevice *dev=0, TransferType type = Binary); int put(const QByteArray &data, const QString &file, TransferType type = Binary); int put(QIODevice *dev, const QString &file, TransferType type = Binary); int remove(const QString &file); int mkdir(const QString &dir); int rmdir(const QString &dir); int rename(const QString &oldname, const QString &newname); //......
-
@Peladosok
As @VRonin saidYou can either recompile the old QFtp Module or use an external library like libcurl
These days you're probably best using libcurl.
There might be some sample FTP client code in Qt example https://doc.qt.io/qt-6/qtscxml-ftpclient-example.html