save txt set in textbox's to INI file (form close) & load text from INI on form load?
So I've got a form with about 7-8 textbox's & i change the data in each like once every 3-4 days. It's a pain filling it all out each time.
So when I close the program, I'd like to save the current data (in each textbox on the form) to a INI file (In the root of whatever current folder I'm running it from)
Then when I load the program the next time, it will load the settings from the INI file to fill my textbox's back up.
Is there a simple way to add this to my program without major changes to my code?
Thanks for any suggestions/code/help!
I know this is kind of day 1 stuff for most programmers. But I had to just jump in running so I missed a lot of the basics!
dim jenn as geek = true
Learning ~ Visual Basic 2010 ~ in free time between college/work -
currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
i am totally super motivated & promise to make an effffin amazing protege!!! #swag
| -_-_- -_-_- |
...W.T..F!?.....
||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||
Re: save txt set in textbox's to INI file (form close) & load text from INI on form l
You can setup each TextBox via the property windows, application ->ApplicationSettings ->PropertyBinding->Text, select new, provide a name. The file will be under App Data\Local i.e. on my Vista machine it would be C:\Users\kevininstructor\AppData\Local\WindowsApplication1 in User.config (it will be one level down from the sample path).
Re: save txt set in textbox's to INI file (form close) & load text from INI on form l
Originally Posted by kevininstructor
You can setup each TextBox via the property windows, application ->ApplicationSettings ->PropertyBinding->Text, select new, provide a name. The file will be under App Data\Local i.e. on my Vista machine it would be C:\Users\kevininstructor\AppData\Local\WindowsApplication1 in User.config (it will be one level down from the sample path).
Yup I just now found a forum post explaining application settings. But like when I've compiled the application & running it on different computers...in different folders etc. Is it going to work then? How do I tell the program to find the config file in the 'same folder' as the program. So then I can just zip up the config & distribute it along with the exe. So like If i give the program to someone else to use...they would run the program in... /desktop/new folder/program.exe & have the User.config in that same folder...which would save their very own settings after it's edited once by them. Or does this only work if you're config is in that 1 location...I'm kinda sorta confused now
It seems like for a portable application, that I will be using on several different pc's, or giving to friends...it would make more sense to use a config.ini wouldn't it?
I mean I'd be cool with saving it to/reading it from a normal text file....or a xml file...or even the registry
Last edited by jalexander; Sep 3rd, 2012 at 02:18 AM.
dim jenn as geek = true
Learning ~ Visual Basic 2010 ~ in free time between college/work -
currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
i am totally super motivated & promise to make an effffin amazing protege!!! #swag
| -_-_- -_-_- |
...W.T..F!?.....
||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||
Re: save txt set in textbox's to INI file (form close) & load text from INI on form l
So is it possible to make the built-in application setting config file portable, so that It can be installed on other PC's, or at least different 'windows logins' on the same PC?
I.E. can u change the root directory of where it looks for the application setting config file?
dim jenn as geek = true
Learning ~ Visual Basic 2010 ~ in free time between college/work -
currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
i am totally super motivated & promise to make an effffin amazing protege!!! #swag
| -_-_- -_-_- |
...W.T..F!?.....
||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||
Re: save txt set in textbox's to INI file (form close) & load text from INI on form l
Originally Posted by jalexander
Yup I just now found a forum post explaining application settings. But like when I've compiled the application & running it on different computers...in different folders etc. Is it going to work then? How do I tell the program to find the config file in the 'same folder' as the program. So then I can just zip up the config & distribute it along with the exe. So like If i give the program to someone else to use...they would run the program in... /desktop/new folder/program.exe & have the User.config in that same folder...which would save their very own settings after it's edited once by them. Or does this only work if you're config is in that 1 location...I'm kinda sorta confused now
It seems like for a portable application, that I will be using on several different pc's, or giving to friends...it would make more sense to use a config.ini wouldn't it?
I mean I'd be cool with saving it to/reading it from a normal text file....or a xml file...or even the registry
Hello,
First off I would not have suggested using this method had you indicated a portable application which never crossed my mind as I would say 99.99% of applications are designed not portable. If you want portable than sure you could use an INI file but that is outdated and require the use of specific API functions. One method that will work is using a xml file located (for you) in the same folder as the main assembly folder. I have attached a VS2008 project I did a while back, converted it just now and tested it to VS2010, Framework 4.
In the attached project the file below saves two check box controls check state and the text property of a TextBox when closing the form, reads the values in at start up and sets the controls.
Note: In the future always provide complete details to what you want which will get you better replies.