Seems to me that File.Exists() is much slower when the file does not exist or the user doesn’t have access than when the file does exist.
is this true?
This doesn’t make sense to me.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Generally when you search a bunch of stuff for something, you can’t be sure about their lack of existence unless you have searched all possible places it could have been. When searching for something (in most kinds of collections) the worst case is when the item doesn’t exist in the collection.
I have not benchmarked
File.Existsin particular but I highly doubt that there’s a really noticeable difference in those cases unless you’re doing it thousands of times. How did you reach to this conclusion?