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:
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.
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?