I have a legacy application that looks for files in a directory. It does not handle missing files very well. What I want to do is “capture” the file not found errors, and send another file back to the calling app instead. Similar to how you could handle a 404 error on a webserver and return something based on what the requested URL was, except on the local file system.
Is this possible? And more preferably, is it possible in .Net?
You can do this by intercepting the call to Win API function CreateFile. This requires dll injection. In .NET you can use this library: easyhook.codeplex.com