I'm trying to load a file that doesn't exist on the file system ( non-existing.file). This type of error can be re-created using a single line of code: try
Could not find file 'filename'Īs the message says, you are trying to load a file that couldn't be found. The Message property on FileNotFoundException gives a hint about what is going on. Let's dig into the different causes of this error. At least I did while digging down into the details for this post.
You may think you know everything there is to know about this exception, but I bet there is something left for you to learn. But, there are actually multiple scenarios that can trigger this exception. Admitted! In all instances this error is caused by trying to access a file that isn't there. Today, I want to help you track down and fix a very common and very well known exception, System.IO.FileNotFoundException. This is the third part in the series named Debugging common.