Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Testing and Deployment

Reply
Developer
annadanesh
Posts: 82
Registered: ‎01-11-2013
My Device: DevAlphadevice
My Carrier: rim
Accepted Solution

Deleting files from QDir

Hi,

 

I have created QDir="data/files/point" in app home dir and storing many files in it.now when i try to delete files under using QDir::remove();&bool QDir::rmdir ( )  ,files are not getting deleted so plz suggest me how to delete files

Please use plain text.
Developer
congdanhqx
Posts: 115
Registered: ‎10-22-2012
My Device: Developer
My Carrier: Mobifone

Re: Deleting files from QDir

May you describe more detail when call

QDir::remove ( const QString & fileName )

 The function

QDir::rmdir ( const QString & dirName ) const

 require the directory must be empty for rmdir() to succeed



Like my answer if it's helpful. Mark as answer if it help you solve the problem.
Please use plain text.
Developer
annadanesh
Posts: 82
Registered: ‎01-11-2013
My Device: DevAlphadevice
My Carrier: rim

Re: Deleting files from QDir

thks for reply

 

I allready tried ur reply before posting ,in first case i have to give filename so that given file is deleted,in second case i have to give dir in this case only if dir is emprty it will be deleted but my requirement is to delete all files in path i specified

Please use plain text.
Developer
congdanhqx
Posts: 115
Registered: ‎10-22-2012
My Device: Developer
My Carrier: Mobifone

Re: Deleting files from QDir

[ Edited ]

This may help you

bool removeDir(const QString& dirName){
    bool result;
QDir dir(dirName); if(dir.exists(dirName)){ QFileInfoList list = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst); Q_FOREACH(QFileInfo info, list){ if(info.isDir()){ result = removeDir(info.absoluteFilePath()); }else{ result =QFile::remove(info.absoluteFilePath()); }
if(!result){ return result; } } result = dir.rmdir(dirName); } return result; }


Like my answer if it's helpful. Mark as answer if it help you solve the problem.
Please use plain text.
Developer
annadanesh
Posts: 82
Registered: ‎01-11-2013
My Device: DevAlphadevice
My Carrier: rim

Re: Deleting files from QDir

thks a lot for ur reply.

 

i have posted one more post regarding downloading image from link(network),still nw i dont got any replay ,so if u know answer plz reply.

 

        QNetworkRequest request = QNetworkRequest();
        QUrl url(res);
        request.setUrl(QUrl("http://intaract.mobi/genericbrowser_images/widget_icons/TELiBrahma_no_result_found_fnZ526.jpeg"));
    mNetworkAccessManager = new QNetworkAccessManager(this);
    bool result = connect(mNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), this,
                    SLOT(onImageLoaded(QNetworkReply*)));
    QNetworkReply* reply = mNetworkAccessManager->get(request);
    qDebug()<<"downloadImage>>>>>>>"<<result<<reply->readAll() ;

 

i am using this code for download image but i am getting QBytearray as null so plz help i am trying this from 2days

Please use plain text.
Developer
congdanhqx
Posts: 115
Registered: ‎10-22-2012
My Device: Developer
My Carrier: Mobifone

Re: Deleting files from QDir

Take a look in this:

https://github.com/blackberry/Cascades-Samples/tree/master/tldr/src

 

Especial in the file

https://github.com/blackberry/Cascades-Samples/blob/master/tldr/src/netimagemanager.cpp

function: constructor and httpFinished

 

You should get the file in your

void onImageLoaded(QNetworkReply* reply)

 function by

reply->readAll()

 



Like my answer if it's helpful. Mark as answer if it help you solve the problem.
Please use plain text.