Help with saving settings

Discuss anything programming related.
Post Reply
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Help with saving settings

Post by Click16 »

Code: Select all

 Me.BlahToolStripMenuItem.DropDownItems.Add(Me.TextBox1.Text)
That adds the text to the tool strip, but i don't know how to save it
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: Help with saving settings

Post by XZodia »

you need to create a "FileStream" and write to it with a "BinaryWriter" and read from it with a "BinaryReader"
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
KIWIDOGGIE
Posts: 72
Joined: Sat Jan 19, 2008 1:32 am
Location: On a Grav Lift
Contact:

Re: Help with saving settings

Post by KIWIDOGGIE »

Or if your lazy just do a filestream/textwriter and have a writeline per setting info. So line 1 = Temp Directory ect.
99% Of the Xbox Scene are retards.
Xbox Scene wrote:All Hail Jester!
User avatar
JacksonCougar
Huurcat
Posts: 2460
Joined: Thu Dec 06, 2007 11:30 pm
Location: Somewhere in Canada

Re: Help with saving settings

Post by JacksonCougar »

Visual Studios does have a built in settings support -_-
Add a Settings document then you can reference it and just grab settings from it on-the-fly. (As well as saving them).
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: Help with saving settings

Post by XZodia »

JacksonCougar wrote:Visual Studios does have a built in settings support -_-
Add a Settings document then you can reference it and just grab settings from it on-the-fly. (As well as saving them).
yea but using it in c# is surprisingly complicated and I couldn't be bothered explaining =P
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
JacksonCougar
Huurcat
Posts: 2460
Joined: Thu Dec 06, 2007 11:30 pm
Location: Somewhere in Canada

Re: Help with saving settings

Post by JacksonCougar »

Yea, I love those random language bugs >_>
Like cannot use System.Linq; >_>
User avatar
OwnZ joO
Posts: 1197
Joined: Sun Dec 09, 2007 4:46 pm

Re: Help with saving settings

Post by OwnZ joO »

What do you mean can't use System.Linq, you probably don't have a reference to the System.Linq assembly.
User avatar
JacksonCougar
Huurcat
Posts: 2460
Joined: Thu Dec 06, 2007 11:30 pm
Location: Somewhere in Canada

Re: Help with saving settings

Post by JacksonCougar »

As in can't use it: I can't find the reference in C#, I have to reference System.Core instead.
User avatar
OwnZ joO
Posts: 1197
Joined: Sun Dec 09, 2007 4:46 pm

Re: Help with saving settings

Post by OwnZ joO »

It's in the System.Core assembly. There is a System.Xml.Linq also though.
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Re: Help with saving settings

Post by Click16 »

I just dont know how to make it save... like that binary writer and reader, I don't know what it is... i need an explanation + sample coding.
Again: im coding with VB
KIWIDOGGIE
Posts: 72
Joined: Sat Jan 19, 2008 1:32 am
Location: On a Grav Lift
Contact:

Re: Help with saving settings

Post by KIWIDOGGIE »

This guy sounds familiar. But when you use a Binary Reader/Writer its like Writing on a sheet of paper; the changes are immediate and final. Its not like you have Change This then Write it to the file; you could make something like that but that is not now the BR/BW combo works.
99% Of the Xbox Scene are retards.
Xbox Scene wrote:All Hail Jester!
User avatar
OwnZ joO
Posts: 1197
Joined: Sun Dec 09, 2007 4:46 pm

Re: Help with saving settings

Post by OwnZ joO »

KIWIDOGGIE wrote:This guy sounds familiar. But when you use a Binary Reader/Writer its like Writing on a sheet of paper; the changes are immediate and final. Its not like you have Change This then Write it to the file; you could make something like that but that is not now the BR/BW combo works.
What are you even trying to say...?
User avatar
Aumaan Anubis
Staff
Posts: 1812
Joined: Thu Dec 13, 2007 12:18 am
Contact:

Re: Help with saving settings

Post by Aumaan Anubis »

You have to make the application create an external file, such as a text document, and have whatever you need to be loaded within the file.

For instance, I want a text box to say, "Happy Birthday!"
Create a text document, and have the only words in it be, "Happy Birthday!"

When the Form you've created loads, have it instantly read the text file and have it display whatever is inside the text file into the text box.

Then, when you want to change what's displayed without having to edit the application, you can just edit whatever is inside the text file.

As for the binary reader/binary writer/file stream stuff, those are all relatively necessary components in code to read/write to a particular file. You would be "reading" from the text file, and therefore you would have to declare a binary reader.

You get what I'm trying to say?

And by the way, I think this is the way to do it...
User avatar
JacksonCougar
Huurcat
Posts: 2460
Joined: Thu Dec 06, 2007 11:30 pm
Location: Somewhere in Canada

Re: Help with saving settings

Post by JacksonCougar »

A better suited method would be to use an xml writer and xml reader, I would get you example code but I don't code VB anymore.
KIWIDOGGIE
Posts: 72
Joined: Sat Jan 19, 2008 1:32 am
Location: On a Grav Lift
Contact:

Re: Help with saving settings

Post by KIWIDOGGIE »

Link

XML in the simplest way. I love CodeProject.
99% Of the Xbox Scene are retards.
Xbox Scene wrote:All Hail Jester!
Post Reply