37. Use QFtp in QT to realize file transfer 2 -- download files or folders from remote server to local

1. Description

There are many cases on the Internet about using the QFtp class to upload files or folders to remote servers, but there are few cases about how to download files, and even fewer cases about downloading entire folders. The method used in this article is to download a single The file is relatively simple, but it adopts a tortuous way when downloading the entire folder. The reason is that if the entire class of ftp still uses a recursive method to obtain the information in the folder in the remote server, it will cause many signal slot functions in QT. connection, there is a problem. Before reading this blog, please read the first blog post: the implementation of uploading files or folders , and expand the functions based on the code of this blog.
Show results:

FTP download files and folders


Project structure:
![Insert picture description here](https://img-blog.csdnimg.cn/973232b2c73e42cca220d58ad6e6b6aa.png)

2. Implementation steps

2.1 Download a single file

The first is to download a single file. This method is exactly the opposite of uploading a single file. What is shown in the code is to exchange the information of the remote file path and the local file path, and use the get() function in ftp to realize the file. Download, the specific code is as follows:

 

Guess you like

Origin blog.csdn.net/FY_13781298928/article/details/131515040