Click here to Skip to main content
15,893,904 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
i save my app user setting in button_click event using .Properties.Settings
this is my code
C#
my_app.Properties.Settings.Default.text1 = TextBox1.Text;
my_app.Properties.Settings.Default.text2 = TextBox2.Text;


and i reload settings in form_load event
C#
TextBox1.Text = my_app.Properties.Settings.Default.text1;
TextBox2.Text = my_app.Properties.Settings.Default.text2;


this works perfectly but i change .exe location my save data are missing

example - i move .exe file from program files to my documents after that i open .exe file(my documents) all data are missing in it
C# / Windows Form Application

why is that ?
any wrong in my code?
any way to keep my setting ?

THANK IN ADVANCE!
Posted
Comments
Sushil Mate 30-Jul-13 0:36am    
where is the .exe.config file?
Manoj Chamikara 30-Jul-13 0:52am    
.config file is in my debug folder but .exe save data and reload save data without .config file so when i change location lost all saved data in .exe
ridoy 30-Jul-13 0:37am    
In my opinion Properties.Settings cause the problem,it saves data in my documents folder by default,so when you change location it won't work.
Sushil Mate 30-Jul-13 0:51am    
if it is stored in the my documents then it shouldn't matter if he changes the exe location, I think the problem lies in the .exe.config file. but I googled & found out this.

In order to work with newer versions of Windows' policy of only allowing read access by default to the Program Files folder (unless you prompt for elevation with UAC, but that's another topic...), your application will have a settings folder under %userprofile%\appdata\local or %userprofile%\Local Settings\Application Data depending on which version of Windows you're running, for settings that are user specific. If you store settings for all users, then they'll be in the corresponding folder under C:\users or C:\Documents and Settings for all user profiles (ex: C:\users\public\appdata\local).

Sergey Alexandrovich Kryukov 30-Jul-13 1:04am    
That's correct, but that's not all which involved. Please see my answer for some more detail.
Of course, I credited your very useful comment.
—SA

1 solution

Please see my comment to the question. Your real problem is just that you did not share enough information on your code.

Also, pay attention for the information Sushil Mate provided in his comment.

Nevertheless, you will most likely sort it out by yourself if your learn the information from my two past answers:
How to find my programs directory (executable directory),
How to find my programs directory (current directory, "special folders").

Good luck,
—SA
 
Share this answer
 
v2
Comments
Sushil Mate 31-Jul-13 0:38am    
looks like OP got the answer. my 5
Sergey Alexandrovich Kryukov 31-Jul-13 1:08am    
Hope so.
Thank you, Sushil.
—SA

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