TomTom
TomTom

Reputation: 62157

Where to store: User connection information?

;) I am writing a .NET application wher ethe user connects to a given server. ALl information within the application is stored in the server. But I want / need to store the following information for the user:

Any idea where to store this best? the application config file is not sensible (user != admin, application.config is write protected for him). So, my options are:

Anyone a tip? Other alternatives? I tend so far to go for the AppData directory with my own subfolder - simply because it is a nice preparation for later to keep like a local copy of configuration etc.

Upvotes: 2

Views: 200

Answers (3)

abatishchev
abatishchev

Reputation: 100358

How to do what dineshrekula wrote below:

using System.Security;
using System.Security.Cryptography;

var guid = Assembly.GetEntryAssembly().GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), false);
this.entropy = Encoding.UTF8.GetBytes((guid[0] as System.Runtime.InteropServices.GuidAttribute).Value);

private SecureString Unprotect(byte[] data)
{
    return UTF8Encoding.UTF8.GetString(ProtectedData.Unprotect(data, this.entropy, DataProtectionScope.CurrentUser)).ToSecureString();
}

private void Protect(string data)
{
    ProtectedData.Protect(UTF8Encoding.UTF8.GetBytes(data), this.entropy, DataProtectionScope.CurrentUser)
}

Upvotes: 0

Dinesh
Dinesh

Reputation: 2066

Encrypt and Save it in the registry.

Upvotes: 1

Hans Olsson
Hans Olsson

Reputation: 55059

You can store in the app.config as a user setting (so they're not really stored in the app.config after they've changed but can be accessed with the same APIs).

See here for more information regarding Scope:

http://msdn.microsoft.com/en-us/library/a65txexh%28VS.80%29.aspx

Upvotes: 1

Related Questions