2

Is there something like shared storage in .net windows forms applications, What I want to do is to build a settings form, where each user can save his own settings on his machine, without the need to explicitly create external files and save the values in these files.

Thanks

Hassan Mokdad
  • 5,832
  • 18
  • 55
  • 90

4 Answers4

4

Maybe Isolated storage suit your needs. Also you can think about registry.

Renatas M.
  • 11,694
  • 1
  • 43
  • 62
2

you can use the "Settings" to do this - just choose "User" instead of "Application" - this way the properties will not be stored into the app.config but onto a nested directory in the users home-directory. You can load/save those settings on runtime too (unlike the app.config settings)

Random Dev
  • 51,810
  • 9
  • 92
  • 119
  • but it will create external files. – Renatas M. Aug 23 '11 at 07:37
  • This way I will have to manipulate these files from my form, and also I want these settings to be invisible to the user, this way the user has the ability to see the settings file – Hassan Mokdad Aug 23 '11 at 07:40
  • yes if the user searches for them he/she will find them - but they are in hidden directories with id-like names and so on. and yes they are external but no you don't have to manipulate the files themselfes. As a sidenote: no matter what you save on a users computer - if the user is clever he/she will allways see it (same if you try to save to the internet) – Random Dev Aug 23 '11 at 07:47
2

Settings have to be stored somewhere, and unfortunately that either means in the Registry (which is heavily abused, and is technically stored in an external file within Windows), in an external file on disk that you create, a remote server (xml over http), or a database. The settings simply have to exist some place they can be loaded again, but the place you choose to write them to is up to you.

I completely understand that you do not want to have to manipulate the file itself by means of reading it, parsing it, then loading. Flip side, getting settings, translating into a config format, and writing to disk. This is an annoying process.

You could use Application Configuration or User Settings, and these are easily visible to the user. If you want something hidden, there really isn't such a thing. A user who really wants to snoop through an applications files, will generally find what they are looking for, and most everything is vulnerable to some degree. You could encrypt your configuration settings, but you still have to work with the file.

My recommendation would be to implement a database like SqlServerCE. Its a file system based database, where the data is not immediately accessible, you can put the file somewhere somewhat hidden (ie. C:\ProgramData\etc\etc), and you don't have to do a whole lot of work. But like I said, what you are asking for requires some work.

Community
  • 1
  • 1
David Anderson
  • 13,558
  • 5
  • 50
  • 76
  • Thanks for your valuable info, but I will go with Renuiz solution concerning Isolated Storage, that's exactly what I needed – Hassan Mokdad Aug 23 '11 at 08:40
1

If you want to setting file invisible to users, Try to save your settings in Registry, instead of Application Settings in User scope, I think this is a suitable way for your application.

Saber Amani
  • 6,409
  • 12
  • 53
  • 88
  • those are not invisible either and as a "user" I would strongly vote against this ... the registry is fragile as it is .. no need to save even more stuff in there :D – Random Dev Aug 23 '11 at 07:48
  • @CKoenig, I know that the way you provided is a good way to save user settings of application state but as you can see in post and comments, he won't user able to see those config file. – Saber Amani Aug 23 '11 at 07:53
  • @CKoenig, I want to hear some reason about why Registry is fragile ? – Saber Amani Aug 23 '11 at 07:59
  • -that's why I put the :D in there - the registry is fine but when you install/uninstall a lot of stuff (trying things out) you will soon find yourself reinstalling windows on a yearly basis because of a lot of bad stuff in there (that even Regcleaners won't to away with) ... but nevermind this is verry OT – Random Dev Aug 23 '11 at 09:12