how to read rext file?
-
hi friends i want to read a txt file using c#. i have some txt files with different informations. ex
txt 1
customr:abc
article:zxy
page number: 4txt 2
customr:fgh
article:ser
page number: 3txt 3
customr:yhu
article:fgr
page number:10the problem is : how i can find the value. how to read this txt file. i tried. but it is reading only if we fave given the full length. i want to find what will be the value of customer of txt 1. plz do help me. thank u.
-
hi friends i want to read a txt file using c#. i have some txt files with different informations. ex
txt 1
customr:abc
article:zxy
page number: 4txt 2
customr:fgh
article:ser
page number: 3txt 3
customr:yhu
article:fgr
page number:10the problem is : how i can find the value. how to read this txt file. i tried. but it is reading only if we fave given the full length. i want to find what will be the value of customer of txt 1. plz do help me. thank u.
string text = File.ReadAllText(filename)
You can then search for different strings within your string using IndexOf, Substring etc. If you don't like this approach study MDSN for System.IO.File class. It has a lot of static methods that can help you read a text file in different ways.
Do your best to be the best
-
hi friends i want to read a txt file using c#. i have some txt files with different informations. ex
txt 1
customr:abc
article:zxy
page number: 4txt 2
customr:fgh
article:ser
page number: 3txt 3
customr:yhu
article:fgr
page number:10the problem is : how i can find the value. how to read this txt file. i tried. but it is reading only if we fave given the full length. i want to find what will be the value of customer of txt 1. plz do help me. thank u.
You can use the readline function of the StreamReader. If the line contains the desired text such as txt 1, then read the next line and you will get the customer name etc.