Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello every body !

I have a problem in my App, plz help me !

Details:

1st prbl

-I have short code set my app start with windows by Registry
with path : D:\MySolution\C#\ManagerStd\Main.exe

however, after i reset my windows, the path in registry change to C:\Windows\Main.exe

I don't understand, why have it change, while i don't have code auto change path Registry !!!

it my Code
C#
string patReg = @"Software\Microsoft\Windows\CurrentVersion\Run";
pReg.OpenSubKey( patReg, true );
pReg.createChildKey( "ServicerRuntimeAutoUpdateDB", Environment.CurrentDirectory + @"\ServicerRuntimeBackupDb.exe" );

with pReg is Instance of class ProgcessRegistry

ps: my english so bad

tks for read !
Posted
Comments
Sergey Alexandrovich Kryukov 2-May-13 9:48am    
I'm not sure your observations are correct. Could you repeat it thoroughly and report exact steps to reproduce the problem?
—SA
NV Quyền 2-May-13 9:57am    
tks U, i was try it, but , the problem error still occurs
Sergey Alexandrovich Kryukov 2-May-13 10:00am    
We can discuss anything only if you provide exact steps to reproduce it. I hope you will cope with English (but please, don't use "text speak" like "tsk", etc.)
—SA
[no name] 2-May-13 9:58am    
"Environment.CurrentDirectory" does not mean that the current working directory is the same as that path to your executable.
Sergey Alexandrovich Kryukov 2-May-13 10:01am    
This is the problem: current directory is never guaranteed to be anything certain at all. It can be anything, as it depends on how user starts it.
—SA

1 solution

Please see the comment by ThePhantomUpvoter and my last comment to the question: current directory can be anything; it depends on the user's way to start your application. You can never rely on that. To see how you can find out some directories, please see my comprehensive answers on this topic:
How to find my programs directory (executable directory),
How to find my programs directory (current directory, "special folders").

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900