I just came across this question telling how to store ListView
Data(basically ListView.Items
) into a text file but it got me thinking that, is it the best way to do it? In terms of efficiency, basically running available operations of the data efficiently, because storing large ListView
Data might take time to access when stored in .txt
format and even storing them might take time. I thought maybe DataSet
with DataTable
might be a proper option. So what is the best option for storing a ListView
Data into file?
1 Answer
If its just a single user application, a file will do. Most applications store configuration in files as well so adding user data file(s) will be easy to do. Most data structures can be serialized into a file with just a few lines of code as long as the class is marked as serializable.
For structures that don't change all that much, one can read them from the file once and then maintain it in memory during the application lifetime. Changes can be saved as needed or persisted back to the file as needed, but runtime access is via the data stored in memory (cache) instead of reading and writing to the file each time. That will alleviate any performance concerns.
Databases are used in web or multi user applications because it's easier to get information from one source for many users as opposed to many files. Plus, a database table can be shared among many users. One cannot have multiple users editing the same file at the same time. Databases offer a level of concurrency not available with a file based approach.
ListView.Items
and run some operations on it. I don't Server SQL systems.