Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
1.00/5 (1 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
etc..


Is there any technique to read line and split it to array or something else with this field? I want to improve performance.
Posted
Comments
Sergey Alexandrovich Kryukov 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.
—SA

1 solution

Yes it seems you're looking for this one http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.fileio.textfieldparser(v=vs.110).aspx[TextFieldParser]

it support fixed with fields without having to substring it yourself
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900