fherrera
07-13-2004, 09:10 AM
Hi there, I just recently found xtremevbtalk and am quite disappointed I hadn't found it earlier! It's an active VB.Net board which for some reason was hard for me to find.
In any case, here's my question.
I am trying to evaluate the many different methods of saving program options. Personally, this is one of my first programs in VB.Net and it is quite small, just basically a GUI for an Excel spreadsheet. In any case, there aren't too many options I'd have to save one of course being a path to where the current spreadsheet lives.
From my experience or lack thereof, here is what I think a decent list:
Write to Registry - I think this might be easy to do in .Net but I'd rather not as I only have a few options to save and well, i'd rather not mess with the registry.
Write to a static file - Either a straight text file or perhaps an XML file (which i'm leaning towards since i've never done it before). Create a format that will suit my needs and write to it and then read from it in order. Simple, right?
Last is some form of serialization - I don't actually know much about this but I read somewhere that you can create a settings class and then serialize it to a file when the program closes and de-serialize the file when the program opens. Umm, I don't actually know anything more than this. But it has been awhile since i've used classes -cough- but the prospects of learning more about serialization add some motivation.
In any case, the static text file seems to be the easiest. I was wondering if everyone agreed or which method you personally use and perhaps why? I'm probably missing some other methods too...?
Last, if the file gets deleted or changed to some invalid format there would have to be some validation when reading it. My guess would be to hardcode some "default" values in the program that it would reset to if no settings file exists, but the "validation" of an improperly changed settings file sounds a bit harder. Just validate each variable as it gets read in and if any of them don't check out start from scratch (back to the default)....
Anyway, your thoughts would be appreciated :D Thanks.
Frank
In any case, here's my question.
I am trying to evaluate the many different methods of saving program options. Personally, this is one of my first programs in VB.Net and it is quite small, just basically a GUI for an Excel spreadsheet. In any case, there aren't too many options I'd have to save one of course being a path to where the current spreadsheet lives.
From my experience or lack thereof, here is what I think a decent list:
Write to Registry - I think this might be easy to do in .Net but I'd rather not as I only have a few options to save and well, i'd rather not mess with the registry.
Write to a static file - Either a straight text file or perhaps an XML file (which i'm leaning towards since i've never done it before). Create a format that will suit my needs and write to it and then read from it in order. Simple, right?
Last is some form of serialization - I don't actually know much about this but I read somewhere that you can create a settings class and then serialize it to a file when the program closes and de-serialize the file when the program opens. Umm, I don't actually know anything more than this. But it has been awhile since i've used classes -cough- but the prospects of learning more about serialization add some motivation.
In any case, the static text file seems to be the easiest. I was wondering if everyone agreed or which method you personally use and perhaps why? I'm probably missing some other methods too...?
Last, if the file gets deleted or changed to some invalid format there would have to be some validation when reading it. My guess would be to hardcode some "default" values in the program that it would reset to if no settings file exists, but the "validation" of an improperly changed settings file sounds a bit harder. Just validate each variable as it gets read in and if any of them don't check out start from scratch (back to the default)....
Anyway, your thoughts would be appreciated :D Thanks.
Frank