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()); file.open(QIODevice::WriteOnly); file.write(reply->readAll()); 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) { downloadFile ("http://www.nseindia.com/content/historical/EQUITIES/2014/OCT/cm01OCT2014bhav.dbf.zip", localpath); msgBox.setText("Your file should be updated now"); msgBox.exec(); } else { // Do something else } qDebug() << __FILE__<<" : " << __FUNCTION__ << " Leaving";
}@
-
Please do not "double post":https://qt-project.org/forums/viewthread/51978/.