NicoVB Posted July 11, 2002 Posted July 11, 2002 What is the best way to save options for your program like sound, file location, and so on??? in XML files, text files??? Quote Visit http://www.nico.gotdns.com Now ONLINE!
Guest Morgon Posted July 12, 2002 Posted July 12, 2002 With the project I'm running, I just use the builtin SaveSetting() and GetSetting() functions. Format (All args are type String): GetSetting(HKCU Folder, SubFolder, Key, Default Value If Key Not Found) SaveSetting(HKCU Folder, SubFolder, Key, Value) (Caveat - This places the folder under "HKCU\Software\VB and VBA Program Settings" - Cool for some of us, but if you're deploying something name-worthy, I'm not sure how to keep it from sticking it there) Example: Dim SaveDir As String = GetSetting("MyProj", "Settings", "FileLocation", CStr(MyDocs) & "\MyProj Personal Files\") Or SaveSetting("MyProj", "Settings", "FileLocation", InputBox1.Text) --- Just as an added bonus, I've seen a lot of people asking for a way to find out the current "My Documents" directory, since it is changeable and will vary on a multi-user machine.. the way I do it is just with a couple little lines at the top: Dim aKey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") Dim MyDocs As Object = aKey.GetValue("Personal") Also note you must use an "Imports Microsoft.Win32" to use the RegistryKey type Hope this helps! -Morgon Quote
NicoVB Posted July 12, 2002 Author Posted July 12, 2002 Hmmm, but is there not something with a config XML file??? I heard something about this, but don't know very sure. BTW : The GetSetting and SaveSetting Functions: were are your options saved???? Quote Visit http://www.nico.gotdns.com Now ONLINE!
*Gurus* divil Posted July 12, 2002 *Gurus* Posted July 12, 2002 I like using XML, check out the XMLTextReader and XMLTextWriter classes. 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
NicoVB Posted July 12, 2002 Author Posted July 12, 2002 yes, I know the XML namespaces, but what is safest manner, and the easiest?? Quote Visit http://www.nico.gotdns.com Now ONLINE!
Guest Morgon Posted July 12, 2002 Posted July 12, 2002 I'm curious.. why is XML better than using the registry, or even just an INI file? Is it "coolness factor" or is there some real benefit? Quote
reboot Posted July 12, 2002 Posted July 12, 2002 I'm not positive, but I suspect you may have hit the nail on the head with your "coolness factor" comment. :) Quote
*Gurus* divil Posted July 12, 2002 *Gurus* Posted July 12, 2002 You only say that because you're not cool 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
Guest _RIP_DREAMS Posted July 15, 2002 Posted July 15, 2002 xml r0x are easy to see and easy to use Quote
Guest Morgon Posted July 15, 2002 Posted July 15, 2002 Okay, well Captain '37337'.. why does XML 'rox' .. is it just like an INI file, or what? I've only seen XML as its own file.. so is it just "INI 2.0" or what? Someone enlighten me :) Quote
*Gurus* Thinker Posted July 15, 2002 *Gurus* Posted July 15, 2002 Everything taken together, XML is to INI as the ocean is to small pond. That doesn't mean it would be better when all you need is a simple way to save some options, but as has been said, XML is on the MS marketing machine top 10 list. Quote Posting Guidelines
Guest SoTTo Posted July 19, 2002 Posted July 19, 2002 The GetSetting and SaveSetting Functions: were are your options saved???? HKEY_CURRENT_USER - software - VB and VBA Program Settings - application name (you can specify this one) - subkey (you can specify this one to - value (pretty logic that you can specify these too) 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.