I am having a weirdest situation with my .NET app right now. When I start the application inside the Visual Studio (debug build), it opens and loads an .xml file located at C:\ProgramData\MyApp\Settings.config
.
The only problem is, this file doesn't exist. I deleted it to clear all settings, but the app is still loading it (my old settings). In release mode, it properly detects that there are no settings, and creates a new file. But when I delete it and restart inside debugger, it loads the previous file again.
I have placed a breakpoint over the line where I'm loading it, and the filename is clearly the one mentioned above. I even deleted the whole folder (C:\ProgramData\MyApp
), and the app is still loading it. When I copy the exact string at my breakpoint into Windows Explorer, it says that there is no such file. But the FileStream
is created, it has the correct length, and XmlSerializer
reads it entirely.
I can see all files in Windows Explorer (hidden and system), I've even tried deleting the folder. I also don't have any NTFS junctions and similar stuff.
Where is Visual Studio loading this file from?
[Edit]
Thanks to @MichaelBurr's comment below, I've found out (using Process Monitor) that the file is being read from C:\Users\MyAccount\AppData\Local\VirtualStore\ProgramData\MyApp\Settings.config
. This "redirection" happens only in debug mode (even in a brand new test console app I just wrote, for that specific file).
Can anyone explain why this is happening?
[Edit2]
Don't know if this helps, but: at some point, I installed and uninstalled the release version of this app on my machine using its WiX installer. If Visual Studio was also running at that time, is it maybe possible that it decided to create a "virtual copy" of this folder for its own purposes?
If yes, how do I make it use the absolute path again?