Which property should I use for a "safe" settings file storage?

T

trant

I would like to know from which property do I get the path to a safe file
storage area for my application, safe as in it will work for any version of
Windows without any default Windows security form the newer OSs screaming
bloody murder. I will need read/write access to the file I put there as my
program is run.
 
A

Alberto Poblacion

trant said:
I would like to know from which property do I get the path to a safe file
storage area for my application, safe as in it will work for any version
of
Windows without any default Windows security form the newer OSs screaming
bloody murder. I will need read/write access to the file I put there as my
program is run.

Have you considered using Isolated Storage? This is a feature of .Net
that assigns to your application a storage area which is allocated for its
private use and should never conflict with any other application in any
version of the operating system.

Example:

IsolatedStorageFile isoStore =
IsolatedStorageFile.GetUserStoreForAssembly();
IsolatedStorageFileStream isoStream =
new IsolatedStorageFileStream(
"file.txt", FileMode.Create, FileAccess.Write, isoStore);
isoStream.Write(buffer, 0, buffer.Length);
isoStream.Close();
isoStore.Close();
 
J

Jeff Gaines

I would like to know from which property do I get the path to a safe file
storage area for my application, safe as in it will work for any version of
Windows without any default Windows security form the newer OSs screaming
bloody murder. I will need read/write access to the file I put there as my
program is run.

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
for the current user. CommonApplicationData for all users.
 
T

trant

Alberto Poblacion said:
Have you considered using Isolated Storage? This is a feature of .Net
that assigns to your application a storage area which is allocated for its
private use and should never conflict with any other application in any
version of the operating system.

Example:

IsolatedStorageFile isoStore =
IsolatedStorageFile.GetUserStoreForAssembly();
IsolatedStorageFileStream isoStream =
new IsolatedStorageFileStream(
"file.txt", FileMode.Create, FileAccess.Write, isoStore);
isoStream.Write(buffer, 0, buffer.Length);
isoStream.Close();
isoStore.Close();

.

Thanks- I have not tried this!

Will this cause any problems with new versions of my software? For example
if I have version 1.0 which creates a file and places it in the isolated
storage and then I release an updated 1.1 will it see the same file?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top