Windows Develop Bookmark and Share   
 index > Windows Forms General > WinForms - which is easiest approach for persisting some data? (e.g. csv file/xml file/registry/other??)
 

WinForms - which is easiest approach for persisting some data? (e.g. csv file/xml file/registry/other??)

Hi,

Just building my first WinForms application.

Question - What's the easiest/best approach for saving some data between use of the application (e.g. list of URL with status & date/time in this case)? I don't see any need for a database.

For example

  • Is just storing to text file easiest?
  • Or is storing to XML file just as easy in DotNet
  • How about Windows Registry - is this something generally to avoid? Is it's use compatible across all versions including Windows 7 * Database - probably overkill here
  • A widely used library perhaps?

Thanks

callagga  Saturday, September 19, 2009 3:55 AM
I'd use an XML file. Especially if you use DataSets in your app, because writing a DataSet to an XML file is practically a no-brainer using the WriteXml() method of a DataSet.
~~Bonnie Berent [C# MVP]
  • Marked As Answer bycallagga Saturday, September 19, 2009 11:49 AM
  •  
BonnieB  Saturday, September 19, 2009 4:42 AM
I'd use an XML file. Especially if you use DataSets in your app, because writing a DataSet to an XML file is practically a no-brainer using the WriteXml() method of a DataSet.
~~Bonnie Berent [C# MVP]
  • Marked As Answer bycallagga Saturday, September 19, 2009 11:49 AM
  •  
BonnieB  Saturday, September 19, 2009 4:42 AM
As BonnieB says, Xml is a great way to store your data. However, it looks like you are talking about application settings. In that case, I recommend you to use the built-in support for settings in .NET. You can then simply use the (strong typed) properties like this:

Properties.Settings.Default.MyUrl

Storing a value is very simple as well:

Properties.Settings settings = Properties.Settings.Default;
settings.MyUrl = "http://www.catenalogic.com";
settings.Save();
Then you don't have to worry about the file format yourself, neither do you have to worry where you store your files.
Geert van Horrik - CatenaLogic
Visit my blog: http://blog.catenalogic.com

Looking for a way to deploy your updates to all your clients? Try Updater!
Geert van Horrik  Saturday, September 19, 2009 11:19 AM
thanks guys
callagga  Saturday, September 19, 2009 11:49 AM

Hi,

If saving some application settings is what you're looking for (as Geert says), you might want to get started here: Application Settings for Windows Forms.

Regards,
Jie
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com


Please remember to mark the replies as answers if they help and unmark them if they provide no help.

If you have any feedback, please tell us.

The CodeFx Project
My Blog (in Simplified Chinese)
Wang, Jie  Monday, September 21, 2009 6:50 AM

You can use google to search for other answers

Custom Search

More Threads

• Checkboxcell in datagridview once again...
• Taskbar events
• Change sort Arrow color
• Getting the current system settings for regional settings
• Enter Key, Dont Validating Yet
• Help with C# syntax
• Creating sub-windows out of controls?
• Images in ListView display with strange black outline
• stop resize form window
• Issue when Printing using WebBrowser (Windos.Forms) in Console Application