This code is easy to check up under the debugger. You should always use the debugger is such cases. You could compare the file name you calculated with what you expect. If you see the difference and don't understand you, it would make a good correct question for CodeProject.
Two recommendations for you:
The most universal way of calculating executable directory is this:
string exePath =
System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetEntryAssembly().Location));
Please try. Some other methods depends on where you host the code, in application, service, Visual Studio runtime host, etc.
Now, as you place your image in the executable directory, it means you use it read-only.
I suggest you use resources instead.
Don't add an image to your directory. Create a .resx resource. Edit it by using "Add resource" => "Add existing file". Add a file. If a file was not in the same directory with the resource file, it will be copied there, so be careful not to keep multiple copies of the same file. Also, this file will be added to the project structure, and its reference will be added to your resource. Open the property of the project node representing your image file. You will see that it is not to be copied in output of the build. It will be places in resource embedded in your executable file. You will see that Visual Studio auto-generated code file, in a child node of the node representing the resource file. Open this file and locate a static class and its static property with the name resembling the name of your image file you used on input. Use this property to access the resource; don't use resource manager and string name of the resource — this is not really supportable way.
Use the property. If, for example, your image file is PNG, the property will be of the type
System.Drawing.Bitmap
. You won't need to match resource name, read image data from resource stream, etc. Just use the bitmap instance.
One more benefit: it will protect your images from modification by the user. If you also sign your assembly it would make the modification of your images nearly impossible.
—SA