I use xml serialization for that sort of thing. There are tons of articles
all over the net and on msdn.microsoft. com that explain the ins and outs of
it. To briefly illustrate, here is some code samples (not production code
of course...but illustrative code).
// A simple user class to illustrate the idea
// "User.cs".
public class User
{
public bool ShowSplashScree n; // make sure we're public or add a
public property get/set
public string Name;
public User(string name)
{
ShowSplashScree n = true;
Name = name;
}
}
// Use something like this to load/save the user settings.
// You will need to add references to System.IO, System.Xml.Seri alization,
and System.Windows. Forms
// "someclass. cs"
private User _MyUser;
.....
public bool LoadUserSetting s()
{
string fileName = Application.Use rAppDataPath + @"\usersettings .xml";
// UserAppDataPath ensures that it uses the logged on user's ApplicationData
folder.
if (File.Exists(fi leName))
{
XmlSerializer ser = new XmlSerializer(t ypeof(User));
FileStream fs = new FileStream(file Name, FileMode.Open);
try
{
_MyUser = (User) ser.Deserialize (fs); // Note that you do not
need to create a new User first before trying to deserialize one.
return true;
}
finally
{
fs.Close();
}
return false;
}
public bool SaveUserSetting s()
{
string fileName = Application.Use rAppDataPath + @"\usersettings .xml";
XmlSerializer ser = new XmlSerializer(t ypeof(User));
FileStream fs = new FileStream(file Name, FileMode.Create );
try
{
ser.Serialize(f s, CurrentUser);
return true;
}
finally
{
fs.Close();
}
return false;
}
HTH,
ShaneB
"Todd Beaulieu" <Todd
Be******@discus sions.microsoft .com> wrote in message
news:C3******** *************** ***********@mic rosoft.com...
Hello,
I'm using the configuration block to store user settings in the app.config
file. As this exe will reside on a network drive, I can't have users
trying
to update the master app.config file. I want each user to read/write to a
file in their user directory.
Does anyone know how to do this?