在C#中更改.exe位置时丢失保存数据 [英] missing save data when change the .exe location in C#

查看:63
本文介绍了在C#中更改.exe位置时丢失保存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用保存我的应用用户设置 .Properties.Settings

这是我的代码

 my_app.Properties.Settings.Default.text1 = TextBox1.Text; 
my_app.Properties.Settings.Default.text2 = TextBox2.Text;





和i 在form_load中重新加载设置事件

 TextBox1.Text = my_app.Properties.Settings.Default.text1; 
TextBox2.Text = my_app.Properties.Settings.Default.text2;





这个完美无缺我更改.exe位置我的保存数据丢失



示例 - 我移动 .exe 文件< b>从程序文件到我的文档之后我打开.exe文件(我的文档)中缺少所有数据

C#/ Windows Form Application



为什么会这样?

我的代码中错误

任何方式保持我的设置



感谢提前!

解决方案

请参阅我对该问题的评论。你真正的问题只是你没有在你的代码上分享足够的信息。



另外,请注意Sushil Mate在评论中提供的信息。



尽管如此,如果你从我过去的两个答案中学到信息,你很可能会自己解决这个问题:

如何找到我的程序目录可执行目录),

如何查找我的程序目录当前目录,特殊文件夹) 。



祝你好运,

-SA

i save my app user setting in button_click event using .Properties.Settings
this is my code

my_app.Properties.Settings.Default.text1 = TextBox1.Text;
my_app.Properties.Settings.Default.text2 = TextBox2.Text;



and i reload settings in form_load event

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!

解决方案

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


这篇关于在C#中更改.exe位置时丢失保存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆