Click here to Skip to main content
15,917,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this in my file txt file:

#
abcdef
##
hijkl
##
mnop

Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText("C:\Users.test.txt")
txtStrip.Text = System.Text.RegularExpressions.Regex.Match(fileReader,(\#)([\s\S]+)(\##)).ToString()

I want to execute in my code is between # and the first ## which is = abdef only

How I'm going to edit that code ? I'm using vb.net
Posted
Updated 12-Sep-13 15:56pm
v2

1 solution

As your input files are apparently small, you can do the following: use System.IO.File.ReadAllLines (instead of ReadAllText. This method returns your an array of strings each representing, surprisingly, a line. Access array elements by index and use the line(s) you need.

Please see: http://msdn.microsoft.com/en-us/library/system.io.file.readalllines.aspx[^].

[EDIT]

gogole_yuna asked:
what if my txt file is big..?
Then you would simply use System.IO.StreamReader with the method ReadLine. Count lines as you read. Pick the one(s) you need. Please see:
http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx[^].

—SA
 
Share this answer
 
v2
Comments
gogole_yuna 12-Sep-13 23:57pm    
what if my txt file is big and i need to do by that why ?
Sergey Alexandrovich Kryukov 13-Sep-13 0:11am    
Please see the updated answer, after [EDIT].
—SA
gogole_yuna 13-Sep-13 0:26am    
thanks :)
Sergey Alexandrovich Kryukov 13-Sep-13 1:43am    
You are very welcome.
Good luck, call again.
—SA

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