Jump to content
Mike Torrettinni

Any advice when to use FileExists?

Recommended Posts

7 minutes ago, Sherlock said:

Just for completeness sake it should be noted, that FileExists will raise an exception, if the current user has insufficient rights to read the file.

in the very next second it could have the rights and vice versa

Share this post


Link to post
4 hours ago, Sherlock said:

Just for completeness sake it should be noted, that FileExists will raise an exception, if the current user has insufficient rights to read the file.

In what version of Delphi is this? Are you sure that it raises an exception? If it does then that is a change of behaviour from the XE days.

  • Like 2

Share this post


Link to post
7 hours ago, Sherlock said:

Just for completeness sake it should be noted, that FileExists will raise an exception, if the current user has insufficient rights to read the file.

I don't have an up-to-date version to verify this with, but I seriously doubt what you claim is true.  Up to at least XE8, FileExists() was never coded to raise any exceptions.  I can't imagine Embarcadero would ever add exception handling to FileExists() in the years since that release.

Edited by Remy Lebeau
  • Like 1

Share this post


Link to post

Just happened to me in at least 10.4.2 may even be so in 11.2. But maybe it is something else, will try to put together a small demo, time permitting.

Edited by Sherlock
Own stupudity

Share this post


Link to post

So, I have no Idea, what the issue really is, it is not FileExists. At least the way I try to reproduce missing privileges no exception is raised... so I retract that statement as bogus. Sorry for the fuss.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×