I recently received a a large text file (many megabytes) which was a concatenation of many different smaller files. The smaller files where of different size and the separated by a particular character. I did a quick Google search, but almost all of the file splitting applications available split files based on size.
I needed to split a file based on a certain ASCII character.
Written using C#, my text file splitting app is extremely simple.
Read the entire text file into a string variable
Using the string function 'Split', create a string array.
Iterate through the string array, and write each to a separate file.
That's it!!!
While there is some beauty in simplistic design, the differentiating aspect of this application is the status screen.
All of the file reading\splitting\writing is contained within the class 'Splitter'. I have tried to keep it independent of the application so that
it could be re-used within other applications if needed. Thus it cannot know about the application, it's forms or controls.
However, I do want my applications (that use this class) to provide the user some feedback on how the splitting process is proceeding. I have achieved this by raising 'events' within the splitter class.
First of all the event delegate's need to be defined, they are defined globally but still within the 'splitter' class.
Then the events need to be declared within the class.
Then the events can be raised within the code of the class.
If you would like to download the application, or the full source code, please go to the Text File Splitter Project.