Domanda

(Using Qt 4.7) I have a function that needs to take a user input of a directory name, then loop through files in a directory by that name on an FTP server. The ftp address is constant so I have it hard-coded in. So far I have this:

QString dir_name = /*whatever the user inputs*/;
QString source = "ftp://username:password@ftp.myftpaddress.com/" + dir_name + "/";
QDirIterator it(source, QDirIterator::NoIteratorFlags);

while(it.hasNext())
{
  //do things with each individual file...
}

However, when I run this it never enters the loop. I put in print statements to help debug and it keeps saying that the directory referred to by it is empty, even though it isn't. I tried simply copy and pasting the result for source into a browser and it is correct. I have used both FTP servers and QDirIterator before but never together, is there something special I need to do to get it to work?

È stato utile?

Soluzione

I have used both FTP servers and QDirIterator before but never together, is there something special I need to do to get it to work?

Nothing special, it just will not work because QDirIterator works with local files. It does not support network drivers as such. You would need to handle the iteration yourself.

I am sorry for being the worse news.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top