Downloading data ZIP file from website



  • Hi Experts ,

    I am downloading data from www.nseinda.com
    and the link is "http://www.nseindia.com/content/historical/EQUITIES/2015/JAN/cm12JAN2015bhav.csv.zip"

    But i am downloading 0 size file ..

    anything wrong ? or any working program for downloading files from web?

    @downloader::downloader(QObject *parent) :
    QObject(parent)
    {
    qDebug() << FILE<<" : " << FUNCTION << " Entering";
    myprocedure();
    qDebug() << FILE<<" : " << FUNCTION << " Leaving";
    }

    void downloader::downloadFile(const QString &url, const QString &aPathInClient)
    {
    qDebug() << FILE<<" : " << FUNCTION << " Entering";
    QNetworkAccessManager m_NetworkMngr;
    QNetworkReply *reply= m_NetworkMngr.get(QNetworkRequest(url));
    QEventLoop loop;
    QObject::connect(reply, SIGNAL(finished()),&loop, SLOT(quit()));
    loop.exec();
    QUrl aUrl(url);
    QFileInfo fileInfo=aUrl.path();

    QFile file(aPathInClient+"\\"+fileInfo.fileName(&#41;&#41;;
    file.open(QIODevice::WriteOnly&#41;;
    file.write(reply->readAll(&#41;);
    
    delete reply;
    qDebug() << __FILE__<<"   :  " << __FUNCTION__ << " Leaving";
    

    }
    void downloader::myprocedure()
    {
    qDebug() << FILE<<" : " << FUNCTION << " Entering";

    QString path;
    QString localpath;
    QMessageBox msgBox;
    QMessageBox msgBox2;
    
    path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
    
    path = "C:/Users/ryerajan/build-untitled2-Desktop_Qt_5_3_MinGW_32bit-Debug/base/download/cm01OCT2014bhav.dbf.zip";
    
    localpath = path;
    

    // QMessageBox msgBox2;
    msgBox2.setText("You can download the update from the web.");
    msgBox2.setInformativeText("Do you want to download the file now?");
    msgBox2.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    msgBox2.setDefaultButton(QMessageBox::Yes);
    int ret = msgBox2.exec();

    if (ret == QMessageBox::Yes&#41; {
    
        downloadFile ("http://www.nseindia.com/content/historical/EQUITIES/2014/OCT/cm01OCT2014bhav.dbf.zip", localpath&#41;;
    
        msgBox.setText("Your file should be updated now"&#41;;
        msgBox.exec(&#41;;
    
    }
    
    else {
    
        // Do something else
    
    }
    
    qDebug(&#41; << __FILE__<<"   :  " << __FUNCTION__ << " Leaving";
    

    }@


  • Moderators


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.