Click here to Skip to main content
13,090,930 members (41,777 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 19:58pm
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 19 Mar 2014
Copyright © CodeProject, 1999-2017
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