c# - Application.StartupPath is changed after app is added to msconfig startup -


and thank taking time me.

i have app i'm adding startup in registry code:

registrykey setrunatstartup = registry.localmachine.opensubkey  ("software\\microsoft\\windows\\currentversion\\run", true);         setrunatstartup.setvalue("mls", application.executablepath.tostring()); 

and have ini.xml file needs in same folder app. access in manner:

xmldocument doc = new xmldocument();         doc.load(application.startuppath.tostring() + "/ini.xml"); 

the problem is, after rebooting computer application.startuppath no longer returning old path returns c:\windows\system32\myapp.exe, throws exception: cannot find needed ini.xml in folder. how can fix this? need method return real path in order access ini.xml. thank you!

don't use current working directory. instead use:

assembly.getexecutingassembly().location 

like so:

path.combine(     path.getdirectoryname(assembly.getexecutingassembly().location),     "myinifile.ini") 

Comments

Popular posts from this blog

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

Android Gson.fromJson error -