Link to home
Start Free TrialLog in
Avatar of Matrix1000
Matrix1000

asked on

Best way to save user info/settings?

I'm writeing a vb.net program where I would like to save users login/passwords/phonenumbers and stuff so they don't have to re-enter them each time.
What would be the best way to accomplish this. I'd like to write/read them from a file of some sort such as an XML file or .ini file and would like to stay away from using an access database.

What is the industry standard/common way to do this?
How would I create the file and save information to it, read it, AND be able to re-save to it, like if a users password changes etc.

Thanks for any advice or code examples :)
Avatar of RonaldBiemans
RonaldBiemans

Hi Matrix1000,

How secure do you want this to be ?

Avatar of Matrix1000

ASKER

it doesn't have to be secure
Hi Matrix1000,

In that case I would write a small class with the information I want to keep and use a soap or binaryformatter to serialize it to an xml file. If you would like I could write some example on how to do that.
ASKER CERTIFIED SOLUTION
Avatar of RonaldBiemans
RonaldBiemans

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
True , very true TheLearnedOne.
Been there, done that :)

Bob
THANKS!!!!!!!!!!!!!!!!!!!!!!!!!
How would I read the saved settings?
Is reading the settings as easy as.......

    Private Sub Button2_Click()
        Dim x As New mysettings()

        'loads the xml document
        x.LoadXML("c:\test.xml")

        'makes the login and pass fields show the saved settings
        txtlogin.Text = x.Login
        txtpass.Text = x.Password
    End Sub
Yep, it is that easy
hmm the saving part works GREAT! but I cant seem to figure out how to read the data again...the example below doesn't work right; the textboxes don't fill in

        'loads the xml document
        x.LoadXML("c:\test.xml")

        'makes the login and pass fields show the saved settings
        txtlogin.Text = x.Login
        txtpass.Text = x.Password
What does the file contents for c:\test.xml look like?

Bob
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<a1:mysettings id="ref-1" xmlns:a1="http://schemas.microsoft.com/clr/nsassem/WindowsApplication10/WindowsApplication10%2C%20Version%3D1.0.1829.16012%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull">
<Login id="ref-3">lllll</Login>
<Password id="ref-4">pppppp</Password>
<Tel1 xsi:null="1"/>
<Tel2 xsi:null="1"/>
</a1:mysettings>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
That's a curious thing, because the XML file has the necessary contents.

Bob
Sorry Matrix1000, my mistake, it should be

Dim x As New mysettings
x = x.LoadXML("c:\test.xml")
TextBox1.Text = x.Login
TextBox2.Text = x.Password
You can also remove the new like,

Dim x As mysettings
x = x.LoadXML("c:\test.xml")
TextBox1.Text = x.Login
TextBox2.Text = x.Password
That's interesting, because the first comment was:

        Dim x As New mysettings()

        'loads the xml document
        x.LoadXML("c:\test.xml")

        'makes the login and pass fields show the saved settings
        txtlogin.Text = x.Login
        txtpass.Text = x.Password

and the second was

        'loads the xml document
        x.LoadXML("c:\test.xml")

        'makes the login and pass fields show the saved settings
        txtlogin.Text = x.Login
        txtpass.Text = x.Password

I missed the missing 'Dim x As New mysettings()' line.

Bob