Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
If you are trying to open the file from your list of most recently used files, make sure that the file has not been renamed, moved, or deleted.
Posted
Comments
[no name] 31-Oct-15 1:12am    
bool exists = File.Exists("C:\\myFile.txt");
If you are getting exists value as True then it present, not moved and not deleted otherwise file is not present.
Are you sure the file exists?
Krunal Rohit 31-Oct-15 1:43am    
I've seen this same question yesterday.

-KR
Krunal Rohit 31-Oct-15 1:45am    
And try to open the file from the recently used files location, if it is moved, deleted then it will throw exception.

-KR

The error is pretty explicit: the file you are trying to open does not exist.

This means that either you are trying to open the wrong file, you are trying to open it in the wrong folder, or you didn;t write it in the first place.

So use the debugger, look at your code, and find out what the file name and path is. When you know that, you can play "hunt the file" and see which of the various possibilities is wrong.

But we can't help you with any of that! :laugh:
 
Share this answer
 
This is how: https://msdn.microsoft.com/en-us/library/system.io.file.exists%28v=vs.110%29.aspx[^]. :-)

Put your list of recent files in some menu item or list so you could perform the checkup and form the set if items on the fly, so at the moment of click only valid entries are shown.

—SA
 
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