archer_coal Posted May 1, 2003 Posted May 1, 2003 What is the best method for storing user settings? I have an application that needs to store a few. I don't have much experience with setting them in the registry but i'm willing to learn if that is the best method. INI files are easy enough but they have their limitations and are all to easily deleted or tamperd with. Any opinions and or tutorials for registry editing would be great! Thanks -mc Quote
hog Posted May 1, 2003 Posted May 1, 2003 I tend to use the registry as I think it neater than using ini files. Quote My website
archer_coal Posted May 1, 2003 Author Posted May 1, 2003 RE: yea after doing some research I think the registry is the way to go. In the long run it's probably best to learn that now anyway. btw HOG your quote is too funny man haha. :D thanks Quote
*Gurus* divil Posted May 1, 2003 *Gurus* Posted May 1, 2003 Personally I use XML files. INI hasn't been a recommended means of storing settings since Windows 3.1, and .NET's xcopy deployment mindset lends itself to XML files more than it does to using the registry. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
*Gurus* Derek Stone Posted May 1, 2003 *Gurus* Posted May 1, 2003 INI files aren't even an option anymore. Use XML files, storing them in the user's application data directory and not in the directory of the application. System administrators who have more than three brain cells won't have write/modify permissions set to the Program Files directory. Quote Posting Guidelines
hog Posted May 2, 2003 Posted May 2, 2003 Just out of curiosity, why would you prefer to use and XML over the registry, is there an advantage in doing so? archer_coal, you'd be suprised at how many times I've had to explain it to people.......duh?? :-)) glad u like it Quote My website
*Experts* Nerseus Posted May 2, 2003 *Experts* Posted May 2, 2003 As divil pointed out, an XML file can easily be copied with rest of your application. Using the registry would require an admistrator to go the registry to make any configuration changes. If we're talking about a server-deployed solution, an XML file is WAY easier to manage versus the registry. Also, .NET was made to read configuration information from a config file. Ever notice the "(DynamicProperties)" property on every control? And to extend Derek's point, writing to the registry may require priveleges that you don't want your application to have. Whereas reading an XML file from the current directory is pretty much a given for any application. -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
vnarod Posted May 2, 2003 Posted May 2, 2003 Why do you think XML is better than INI? Especially in a situation where user might need to modify them? Quote
Moderators Robby Posted May 2, 2003 Moderators Posted May 2, 2003 A user can modify an XML file as easy as an INI file. Quote Visit...Bassic Software
*Gurus* divil Posted May 2, 2003 *Gurus* Posted May 2, 2003 vnarod, as I said, INI files have not been a recommended method of storage since Windows 3.1. Time to let them go. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
hog Posted May 3, 2003 Posted May 3, 2003 OK, so now you got me thinking. My app at the moment has a setup form which allows users to specify certain attributes of the application which I write to the registry using SaveSetting and GetSetting. So are you saying I should drop this and adopt the XML approach? I know how to open an XML file and modify it manually by copying the layout already in it, but have no idea how to create one from scratch! Quote My website
AndreRyan Posted May 4, 2003 Posted May 4, 2003 Using XML basics is quite easy Public Sub WriteXML(ByVal Path as String) Dim WriteXML As System.Xml.XmlTextWriter = New System.Xml.XmlTextWriter(Path, System.Text.Encoding.Default) 'Create an XML writer With WriteXML .WriteStartElement("MyXMLfile") 'Write entry .WriteElementString("Hello", "Welcome") .WriteEndElement() 'close root .Close() 'Stop writing End With End Sub Public Function GetXML(Byval Path as String) as String Dim ReadXML As System.Xml.XmlTextReader = New Xml.XmlTextReader(Path) 'Create a reader With ReadXML .ReadStartElement("MyXMLfile") 'Read root GetXML = .ReadElementString("Hello") .ReadEndElement() 'close root section .Close() 'Stop reading End With End Function The XML file looks like this: <MyXMLfile><Hello>Welcome</Hello></MyXMLfile> Quote .Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
hog Posted May 4, 2003 Posted May 4, 2003 Mmm nice one, I'll give this a go....cheers :-) Quote My website
archer_coal Posted May 4, 2003 Author Posted May 4, 2003 Nice! Yes Thanks very much for all the feedback! I'm going to give this a go myself. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.