|
-
May 10th, 2011, 09:12 AM
#1
Thread Starter
Lively Member
[RESOLVED] How to get text from a text file and save it in the application?
So, here's the situation.
I first want my program to get the text from a text file(I know how that's done), but once it gets it, I want to somehow save it that it won't need to get the text again(for example, if you restart the application, it won't need to get the text from the file because the text is already saved). Can you please help me with this?
-
May 10th, 2011, 09:20 AM
#2
Re: How to get text from a text file and save it in the application?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 10th, 2011, 09:23 AM
#3
Re: How to get text from a text file and save it in the application?
If an application wants to save data, it saves it to a file. You can save it to a different file if you want, e.g. a database (which is a file underneath) or the application config file, but it will still be a file of some sort. You can store data inside the EXE itself as a resource, but that is something that you do at compile time.
I would guess that your best bet would be to use an application setting. You create it on the Settings page at design time and you can then assign the text from the other file to the property of My.Settings in code. The value of the setting will then be saved automatically at shutdown and reloaded automatically at startup.
-
May 10th, 2011, 11:32 AM
#4
Thread Starter
Lively Member
Re: How to get text from a text file and save it in the application?
 Originally Posted by jmcilhinney
If an application wants to save data, it saves it to a file. You can save it to a different file if you want, e.g. a database (which is a file underneath) or the application config file, but it will still be a file of some sort. You can store data inside the EXE itself as a resource, but that is something that you do at compile time.
I would guess that your best bet would be to use an application setting. You create it on the Settings page at design time and you can then assign the text from the other file to the property of My.Settings in code. The value of the setting will then be saved automatically at shutdown and reloaded automatically at startup.
I partially get what you are saying, but I don't know how to do it. I have never worked with My.Settings before.
-
May 10th, 2011, 02:19 PM
#5
Thread Starter
Lively Member
Re: How to get text from a text file and save it in the application?
-
May 10th, 2011, 03:13 PM
#6
Re: How to get text from a text file and save it in the application?
Go into Project|Properties and look at the Settings tab. You can add custom settings in there of various types.
Once you have added a setting to hold your information, you would access it for either reading or writing with:
My.Settings.<your setting name here>
It would act pretty much like a variable that is loaded every time your program starts. If you want to add a different number of strings each time, you can use the Specialized.StringCollection type, which would give you something akin to a List (of String).
My usual boring signature: Nothing
 
-
May 10th, 2011, 07:45 PM
#7
Member
Re: How to get text from a text file and save it in the application?
-
May 10th, 2011, 07:59 PM
#8
Re: How to get text from a text file and save it in the application?
Once you've added the setting to your app, all the code you need is basically:
vb.net Code:
My.Settings.SomeSetting = IO.File.ReadAllText("file path here")
-
May 11th, 2011, 12:39 AM
#9
Thread Starter
Lively Member
Re: How to get text from a text file and save it in the application?
 Originally Posted by jmcilhinney
Once you've added the setting to your app, all the code you need is basically:
vb.net Code:
My.Settings.SomeSetting = IO.File.ReadAllText("file path here")
 Originally Posted by HerkyBird
Tutorial here
Thanks guys! I will try this and post the results what happened.
-
May 11th, 2011, 07:33 AM
#10
Thread Starter
Lively Member
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|