How to store persistent data? 
Author Message
 How to store persistent data?

What's the best way to store persistent data in a program like:
  + Configuration options that a user changed.
  + Position of the window.
  + Passwords that were set.

This data could be written to a text file but that's not very
sophisticated or secure.

Thanks for your help.



Mon, 01 Nov 2004 03:43:48 GMT  
 How to store persistent data?
You can use the user's registry for your application, which can be read and
written to with

    Application.UserAppDataRegistry.SetValue(...)
    Application.UserAppDataRegistry.GetValue(...)

If you decide to store settings-type things in file, the best place is
probably Application.UserAppDataPath.  The nice part of these built-in
locations is that they are correct for all Windows configurations (i.e.,
Windows NT 2000 installed on C: and Windows ME installed on D:). It saves
you time by not having to make assumptions about the user's permissions on
any particular directory, etc.

As for security, I have always rolled my own solutions, so I will defer to
other posters who have quicker solutions.

Bret


Quote:
> What's the best way to store persistent data in a program like:
>   + Configuration options that a user changed.
>   + Position of the window.
>   + Passwords that were set.

> This data could be written to a text file but that's not very
> sophisticated or secure.

> Thanks for your help.



Mon, 01 Nov 2004 04:45:01 GMT  
 How to store persistent data?
I think the best way is to use serialization to store it to a file (usually
in the same directory as the application), and then read it back in on
startup.

--
Visit the C# product team at http://www.gotdotnet.com/team/csharp

This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> What's the best way to store persistent data in a program like:
>   + Configuration options that a user changed.
>   + Position of the window.
>   + Passwords that were set.

> This data could be written to a text file but that's not very
> sophisticated or secure.

> Thanks for your help.



Mon, 01 Nov 2004 08:45:03 GMT  
 How to store persistent data?
The problem with storing data in the same directory as the application is
that:

(1) It is not "per-user" without a lot of work.
(2) In many environments, users do not have the permission to write to the
application's directory.

That is why MS introduced the variables I mentioned to .NET, so it would be
less difficult for developers to develop scalable and multi-environment
solutions.

Bret



Quote:
> I think the best way is to use serialization to store it to a file
(usually
> in the same directory as the application), and then read it back in on
> startup.

> --
> Visit the C# product team at http://www.gotdotnet.com/team/csharp

> This posting is provided "AS IS" with no warranties, and confers no
rights.



> > What's the best way to store persistent data in a program like:
> >   + Configuration options that a user changed.
> >   + Position of the window.
> >   + Passwords that were set.

> > This data could be written to a text file but that's not very
> > sophisticated or secure.

> > Thanks for your help.



Mon, 01 Nov 2004 11:56:02 GMT  
 How to store persistent data?
I agree about using <Application.UserAppDataPath>\settings.xml, but
one problem is that the directory is version specific.  When you
upgrade, the old settings need to be copied over to the new directory
by the install or the application.  Is there anything usable as an
alternative to writing this code for every application?

Mark



Mon, 08 Nov 2004 03:29:58 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. DLL with persistent data

2. How to load control persistent data?

3. Persistent App data variables without Registry?

4. Tip on persistent data and the for_each() algorithm

5. Tip on persistent data and the for_each() algorithm

6. Storing data from a datagrid into an XML file

7. Where to store data files?

8. Storing custom data types in a database

9. Recommended data store for desktop app.?

10. data type to store numbers 0-255.

11. Storing cross-platform struct data

12. Storing data from a file into a linked list

 

 
Powered by phpBB® Forum Software