开发者

c# program loses filepaths after autostart

So I got a nice piece of code that allows me to enable autostart of program by clicking one button and disable by clicking other (it uses "SetValue" to create register entry and "DeleteValue" to discard it). I used it in simple pr开发者_Python百科ogram, and it did started with Windows as I wanted. The problem started when I used the same code in more sophisticated program, which saves its settings in files in "debug" folder (which is default location for textreader and textwriter) During startup, it showed exception and when I clicked to continue, it opened with default settings. The funny thing is that it said "System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Documents and Settings\OWner\autostart.txt'." even though autostart.txt was never supposed to be in this folder. I guess that when autostarting, the program starts looking for configuration files in C:\Documents and Settings\OWner\ instead of its own folder. Anyone has any idea why?


You have 2 (or more) options:

  1. Discover the path of where your application executes (various ways to do this).
  2. Set the working directory in your shortcut/launcher.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜