-3

I'm writing a c# utility that needs to filter and display large text files (over 100MB in size).

The utility opens the text file in read-only mode, should allow scrolling through the text, jumping to a specific line number, searching for text patterns and displaying only specific lines according to user defined filters.

I would like my utility to provide the user with access to the file very soon after pushing the "Load" button and this is where I ran into issues:

I was able to overcome the matter of quickly reading the text file into a DataTable, however, when I wanted to display it in my DataGridView, it took just too long to load. I'm using a DataGridView as I will need to display additional columns near each line of the text.

The only suggestion I could find on the net was to display only a portion of the file each time. This solution sounds perfect for my needs, but raises a few issues:

  1. Shortly after loading the file, the user will want to start performing actions such as: moving to a specific line, searching for text or filtering, hence, loading the file asynchronously into the DataGridView is probably not the best solution to my issue.

  2. Other solutions suggested loading the first N lines of file and the last M lines of the file and adding the missing lines as the user scrolls. Here I had issues with mapping the line numbers in the DataGridView to the line numbers in the DataTable: if I scroll to the end and then start scrolling up, or just jump to a specific line number, how do I know which lines have already been loaded and which haven't?

Has anyone ever tackled such an issue before?

meirgold
  • 83
  • 6

1 Answers1

0

DataTable is bulky and slow.

Use WPF and GridView.

Create a class then a List of the class and bind to that.

If you want to dynamically update the UI then ObservableCollection and retrieve data on another thread.

paparazzo
  • 44,497
  • 23
  • 105
  • 176