Hey, I have a problem..

I saved a value in the settings (123456), and it I made a program that it shows in a label the value, and when I'm writing in a textbox a value, then clicking a button it saves me the textbox's value and when I'm exiting the program and run it it saves me the last value.

And then I ran the program in the desktop and it worked perfectly, but when I moved the program to another location, the value was 123456, not the last one I did when the program was in the desktop. When I moved it to the desktop again, it was the last one I did on the desktop, and when I moved it to the other location (the same location [not the desktop]), it saved me the last value I wrote when it was in this location.

My question is, how can I do it to be the same in all locations?

Thanks for helping!

Hi,

You need to store the data in a shared file or on a database. The settings are stored locally in a file on which ever machine the application is deployed on. So if you run an application for the first time on a new deployment it will create the settings file locally with whatever default values have been specified.

Okay, but how can I do that my application will edit the value from the database?

you can store data in the form of txt file...
and txt file can be imported by using stream wrirter...
Whenever you create a txt file will be also created as because of streamwriter which create txt file and when you open your form (form_Load())at this time use the Streamreader and read the file...
But this will not work as a single instance application...

I am doing the same things for my app so i suggest this way

You will have to us a text file to store your values, here is how you can do it because according to your main post you want to first by default write a default value to the file then when you deploy the application it will update the saved value with the current value and when you transfer the file(your program) to another location when you debug it there you want it to not create the new one or show you the default created value but rather the last value that was saved when you deploy or debugged the application in desktop so to do so I will strongly suggest that you use a text file or any other file it can be a database or what ever you feel like using and you will have to add it to your application resources inn VB.NET and to write to it you can use streamReader and StreamWriter to call or refer to it.

This article has been dead for over six months. Start a new discussion instead.