Is there any way of having a VS debug session break when a specific file is read from or written to?
In this case I'd want to use it as an exploratory tool -- assume I don't know where in a large codebase this file is being accessed from, or where the filename is being set -- it might be picked up from deep in some large scale config.
What I would do is just quickly hack up a static class that uses the FileSystemWatcher class to listen to file create/changed events, and put a breakpoint in the event callback, or put a call to System.Diagnostics.Debugger.Break there.
Then, when it breaks, switch to the Threads window and try to locate the thread and the piece of code that did the actual file-access.
If you need to use this a lot, have this class maintain a list of specific file names you want to break on, and expose two public static methods: to Start and Stop listening to changes in a specific file.
Also, if you have VS2010 Ultimate you could simply search through the list of File Created events in the IntelliTrace events log.