0

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?

6
  • Is there a reason you need files specifically and aren't storing and retrieving the ListView data in a database? as a vast generality, reading from a database is quicker than files.
    – Adam Wells
    Sep 26, 2016 at 12:50
  • @AdamWells well I am new to Database that is why I don't know much about Database's properties and its correct usage(practically) therefore I asked what is the most efficient way to store, and retrieve data. If you say Database then my choice will be Relational Database, thanks for the help
    – user196377
    Sep 26, 2016 at 12:58
  • @AdamWells sir, will Microsoft Access be able to do the job for me? Basically I just need to store ListView.Items and run some operations on it. I don't Server SQL systems.
    – user196377
    Sep 26, 2016 at 13:06
  • Probably? I'm not an expert on Access.
    – Adam Wells
    Sep 26, 2016 at 14:29
  • I assume you need to store the data in the data source of the listview. You probably have the data in a structure such as DataTable or DataSet. You could just save it in either text or XML. Don't worry about the size if you are talking 10 thousands or less...PCs are very fast - Test it out and you will see (it all depends on the CPU, Disk Speed, etc) but in general you should be OK.
    – NoChance
    Feb 19, 2022 at 23:33

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.