I assumed (and we all know what that gets you) that My.Computer.Filesystem pointed to where the exe was installed. Most of the time, that premise is holding true. However, occasionally it is pointing to C:\Windows\System32 and my code is failing due to permissions.
So where is it really pointing and why the difference?
Thanks
Instead of using a relative path use Path.Combine()
together with Application.StartupPath
. The latter will get the directory where the .exe was started from.
My.Computer.FileSystem.WriteAllText(Path.Combine(Application.StartupPath, "done.txt"), "0", False, Encoding.ASCII)