开发者

Store ListView data C#

开发者 https://www.devze.com 2023-03-06 19:25 出处:网络
I\'m trying to make me a little program in C # (using Visual Studio 2010) to keep track of the films that I keep on my computer. The interface is just a ListVie开发者_Go百科w with 7 Columns and a Add

I'm trying to make me a little program in C # (using Visual Studio 2010) to keep track of the films that I keep on my computer. The interface is just a ListVie开发者_Go百科w with 7 Columns and a Add button. Add button opens a opendialog and allows me to select the video file. Click on Open and then goes info about the file or files in the ListView table.

I'm wondering if anyone can tell me what would be the best method to store the listview table. So all info that i put into the listview over the time will always appear when i start the program. Maybe like what do I do to get a similar substation such as iTunes, when I add music file and exit the program then run the program later the file will be there not empty listview like i get at this state.

Should i use StreamWriter and textfile or is there a better way?

excuse me if this is complicated. My English not good enough. I am not an experienced programmer.


For something as simple as what you're doing, I serialize to an XML file, and then Deserialize from the same XML file every time the application opens.

If you list of movies gets too big, consider moving to some light-weight database.


I'd suggest using an XmlSerializer to easily save to an xml file, then load (deserialize) from it when your program starts. I've used this successfully in the past.


Just to give another option besides XML. You could use a SQLite database if you are familiar with writing SQL statements. It integrates quite nicely and gives you a relational database to play with.

Two implementations:

  • http://sqlite.phxsoftware.com/
  • http://code.google.com/p/csharp-sqlite/


You could create an xml document and could put your data in xml file. XmlDocument class provides easy way to manipulate and read nodes from xml. But use XmlDocument when your file is not large. MSDN post about XmlDocument.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号