[Qt-interest] QFile::exists on a folder

David Ching dc at remove-this.dcsoft.com
Thu Feb 11 13:01:50 CET 2010


"Mika Rajala" <mika_rajala_2 at hotmail.com> wrote in message 
news:BLU141-W34744024A00C977722A8CEE64E0 at phx.gbl...
> anyway, i think it's better to use QFileInfo to check that it's a file. 
> Although trying to open it is a valid solution as well.

The QFile::exists() and QFileInfo solution together to is the best way 
because it tests exactly what you want to know, not approximate it by 
another technique.  Such as trying to open the file.  Though rare, the file 
could exist but fail to be opened due to e.g. sharing violation or 
permission failure.

-- David




More information about the Qt-interest-old mailing list