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

Native Development

Reply
Regular Contributor
cmr1990
Posts: 59
Registered: ‎10-16-2013
My Device: Z10
My Carrier: vodaphone

File.exists() returns false, even if i'm definately positive the file does exist.

I m creating a QFile in "/accounts/1000/shared/misc/Logs/" ; 

Logs is the folder i'm creating. it gets created, files also get created & can be written into.

using this code to creae the file :

 

_LogFile.setFileName(Logger::logFilePath()) ;
_LogFile.open((_LogFile.exists()) ? (QIODevice::Append) : (QIODevice::ReadWrite) ) ;

 

but if i file _LogFile.exists() it retuns false.

i'm able to see the file in the File Navigator as well as on the phones drive.

also itterating Logs dir gives me the names of all the files including the one i'm fireing .exists on!!

Please Help!!!

Please use plain text.
Developer
BBSJdev
Posts: 6,089
Registered: ‎07-05-2012
My Device: Playbook, Z10 LE, Dev Alpha C
My Carrier: Orange

Re: File.exists() returns false, even if i'm definately positive the file does exist.

[ Edited ]

It's the open command that creates the file so checking for it to exist within the call is too soon.

Move the check to outside the open command.

 

_LogFile.exists()) ? _LogFile.open(QIODevice::Append) ? _LogFile.open(QIODevice::ReadWrite);

 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: File.exists() returns false, even if i'm definately positive the file does exist.


BBSJdev wrote:

It's the open command that creates the file so checking for it to exist within the call is too soon.

Move the check to outside the open command.


Are you certain? Surely OpenMode is passed by value, and thus evaluated in the callers scope before the Open() function is entered...?!

 

Perhaps Logger::logFilePath() is returning just a path, not a path + filename?

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.