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

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -