Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
Hi all,
I am reading .txt file in c#. I have one problem like my txt file contain more then 2000 lines and it will take lots of time to execute because currently i am read line by line and use sub-string function for split data. Each line contain one employee detail. In line i get data into fix position like,
Employee Name     = 0 to 50 Character,
Employee Address  = 51 to 200 Character,
Employee BDate    = 201 to 215 Character,
Employee Gender   = 216 to 220 Character
Is there any technique to read line and split it to array or something else with this field? I want to improve performance.
Posted 18-Mar-14 20:58pm
Sergey Alexandrovich Kryukov at 19-Mar-14 2:09am
Why? Why fixed-size? Array of what? Why do you think it would improve performance?
But I can tell you in advance: such data structure and code design don't make sense.
If you explain your ultimate goals, you may have a chance to get some practical advice.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Yes it seems you're looking for this one[TextFieldParser]
it support fixed with fields without having to substring it yourself

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 19 Mar 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100