Page 1 of 1

Help with saving settings

Posted: Wed Sep 10, 2008 8:31 pm
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

Re: Help with saving settings

Posted: Wed Sep 10, 2008 10:03 pm
by XZodia
you need to create a "FileStream" and write to it with a "BinaryWriter" and read from it with a "BinaryReader"

Re: Help with saving settings

Posted: Wed Sep 10, 2008 10:46 pm
by KIWIDOGGIE
Or if your lazy just do a filestream/textwriter and have a writeline per setting info. So line 1 = Temp Directory ect.

Re: Help with saving settings

Posted: Wed Sep 10, 2008 11:06 pm
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).

Re: Help with saving settings

Posted: Thu Sep 11, 2008 2:15 am
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

Re: Help with saving settings

Posted: Thu Sep 11, 2008 5:13 am
by JacksonCougar
Yea, I love those random language bugs >_>
Like cannot use System.Linq; >_>

Re: Help with saving settings

Posted: Thu Sep 11, 2008 7:32 am
by OwnZ joO
What do you mean can't use System.Linq, you probably don't have a reference to the System.Linq assembly.

Re: Help with saving settings

Posted: Thu Sep 11, 2008 2:07 pm
by JacksonCougar
As in can't use it: I can't find the reference in C#, I have to reference System.Core instead.

Re: Help with saving settings

Posted: Thu Sep 11, 2008 7:16 pm
by OwnZ joO
It's in the System.Core assembly. There is a System.Xml.Linq also though.

Re: Help with saving settings

Posted: Sun Sep 14, 2008 2:04 am
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

Re: Help with saving settings

Posted: Sun Sep 14, 2008 3:02 am
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.

Re: Help with saving settings

Posted: Sun Sep 14, 2008 11:29 pm
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...?

Re: Help with saving settings

Posted: Sun Sep 14, 2008 11:54 pm
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...

Re: Help with saving settings

Posted: Mon Sep 15, 2008 12:56 am
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.

Re: Help with saving settings

Posted: Sat Sep 20, 2008 6:41 pm
by KIWIDOGGIE
Link

XML in the simplest way. I love CodeProject.