Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
File.exist() return false for any C drive file if that file is exist their and valid too.
Posted
Updated 14-May-15 1:03am
v2
Comments
Tomas Takac 14-May-15 7:00am    
File.Exists is swallowing exceptions and returning false instead. Try to use File.Open and see where that gets you.

1 solution

If you mean File.Exists[^] rather than File.exit (which I've never heard of) then the most likely reason is that the user under whom your application is runnign does not have sufficient access persmissions to look at the file:
"true if the caller has the required permissions and path contains the name of an existing file; otherwise, false. This method also returns false if path is null, an invalid path, or a zero-length string. If the caller does not have sufficient permissions to read the specified file, no exception is thrown and the method returns false regardless of the existence of path." -- MSDN
If you don't have permission, you will have to either elevate your application, or run it under a user who does have access - depending on what your application or service is intended to be doing.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900