hi
I ty to download file from ftp server using QFtp::get(),
my probelem is at the end of dowload, the file downloaded is empty

here is the code of download :

Qt Code:
  1. void myMainWindow::downFileSlot()
  2. {
  3. QString fileName = serverDir->currentItem()->text(0);
  4. if( currentServerDir[ fileName ] )
  5. {
  6. QMessageBox::information(this, tr("Client FTP"), tr("Vous devez selectionner un fichier source\n %1 est un dossier") .arg(fileName));
  7. return;
  8. }
  9.  
  10. QDirModel *dirMod = (QDirModel *)(localDir->model());
  11. bool selectedIsDir = dirMod->fileInfo( localDir->currentIndex() ).isDir();
  12. QString path = dirMod->fileInfo( localDir->currentIndex() ).absoluteFilePath();
  13.  
  14. if(selectedIsDir)
  15. {
  16. QFile *file = new QFile(path + "/" + fileName);
  17.  
  18.  
  19. if ( QFile::exists(path + "/" + fileName) )
  20. {
  21. QMessageBox msgBox(QMessageBox::Warning, "FTP Erreur", "Le fichier " + fileName + " existe deja\nVoulez vous le remplacer ?", QMessageBox::Yes | QMessageBox::No, this);
  22. switch ( msgBox.exec() )
  23. {
  24. case QMessageBox::Yes:
  25. break;
  26. case QMessageBox::No:
  27. return;
  28. break;
  29. default:
  30. return;
  31. break;
  32. }
  33. }
  34. if (!file->open(QIODevice::WriteOnly)) {
  35. QMessageBox::information(this, tr("Client FTP"), tr("Impossible d'enregistrer le fichier %1: %2.") .arg(fileName).arg(file->errorString()));
  36. delete file;
  37. return;
  38. }
  39.  
  40. ftp->get(fileName, file);
  41. stopAction->setEnabled(true);
  42. down=new MyTreeWidgetItem;
  43. currentDown[ ftp->currentId() ] = down;
  44. connect( ftp, SIGNAL( dataTransferProgress(qint64, qint64) ), currentDown[ ftp->currentId() ] , SLOT( progressTranferDataSlot(qint64, qint64) ) );
  45. listDown->addTopLevelItem( currentDown[ ftp->currentId() ] );
  46. currentDown[ ftp->currentId() ]->setLine(1, fileName);
  47.  
  48. dirMod->refresh();
  49. }
  50. else
  51. {
  52. QMessageBox::information(this, tr("Client FTP"), tr("Vous devez selectionner un dossier destinataire\n %1 est un fichier") .arg(path) );
  53. }
  54. }
To copy to clipboard, switch view to plain text mode 

can you help me pleaz
thanks