text: Reading a Delimited File using ASP.Net and VB.Net
  In this article I am going to explain how to read delimited file using dot net languages
  To read files using .Net we need to declare a namespace called SYSTEM.IO, which contains a set of classes and methods used for reading and writing files.
  Let us now declare a namespace with the name of System.IO:
  <%@Import Namespace="System.IO"%>
  Next, we open the script tag, which will run on the server. We also specify our scripting language as vb in the tag:
  <Script language="vb" runat="server">
  Next, we shall think about where to write the function, we shall write coding when the page loads, and we shall declare the Subroutine, which fires when the page loads. Let us now declare the subroutine
  Sub page_load (Sender As Object,e As EventArgs)
  We need to specify a filename which is to be read – whether it is a text file or a . csv file, the filename in order to open that file:
  filestream = File.Opentext(filetoread)
  In the above code we use the Opentext method of the streamer and pass the variable filetoread – the variable filetoread contains the filepath.
  While streamer reads the content, we now need a place to store the contents of the file. We will have to declare a variable named readcontents with data-type string, which will store the contents of the file:
  Dim readcontents as String
  Using the ReadToEnd method of the streamer we read the entire contents of the variable readcontents:
  readcontents = fileStream.ReadToEnd()
  Now we will have to declare a variable, which will store the delimiter. Let us declare the variable named as textdelimiter with the data-type string.
  Dim textdelimiter as String
  Next, we’ll assign the delimiter, which may be a letter, word, number etc. For this example we’ll = “ “
  The value of the variable is mandatory and is very important, as the reading of the delimited file depends on the value that is stored in the variable.
  After we’ve specified the delimiter, we now split the contents of the files using the specified delimiter. In order to do that we’ll declare a variable named splitout. We’ll then use the split function to split the text.
  Dim splitout = Split(readcontents,textdelimiter)
  In the above code we have declared a variable named splitout. To that variable we are assigning split functionality.
  The Split function contains two parameters: the first is the content, the second is the delimiter. The contents of the file are split according to the delimiter passed. The split contents are then stored in the form of arrays. To exhibit the output we will use two asp: labels, whose text will be assigned dynamically. Let us place a label out of the </script> tag
  <asp:label
  The above tag should be placed outside of the </script> tag.
  Now we declare a variable i with data-type integer, which may be wondering how splitout has become an array. Whenever you use the split function, the variable that is used for splitting is automatically converted into an array.
  Starting from zero which is our lower limit until the upper limit we write the text to the asp:label .
  lblsplittext.Text &= "<b>Split </b>" & i+1 & ") " & splitout(i)& "<br>"
  In the above code, using lblsplittext.text we dynamically assign the value to the asp:label named lblsplittext. We’ll take a look at the next section of that code.
  Here we use the <b> (bold) tag, which is a normal HTML tag. Here, it’s simply used to bold the text. We then concatenate the variable i which is in the loop (i displays a serial number)
  "<b>Split </b>" & i+1 & ")
  In the next part
  " & splitout(i)& "<br>"
  We are concatenating the variable splitout (i), which we would see that variable i is passed to the splitout variable. Here the concept of passing i is as follows: We know that splitout is an array, the lower limit of an array starts from zero. Since this splitout(i) is within the loop, the variable passes from the lower limit to the upper limit, when it goes through loop it looks like this:
  splitout(0), then splitout(1), then splitout(2) until the upper limit.
  To navigate to the next array element using the for loop then we use the Next key word. In order to differentiate the file contents and the read delimited contents, we shall display the files contents to an asp: label directly – which is raw without any split. Now let us place the tag after the </script> tag
  <asp:label
  We dynamically assign the label’s text with the contents read from the file.
  lblplaintext.text = readcontents & "<br>"
  In the code above, we concatenate a “<br>” just to break the line (for readability purposes). Now we close the stream class object in order to release the resources:
  filestream.Close()
  After we close the stream object, we close the subroutine, and close the script tag:
  End Sub
  </script>
  After closing the script tag we will be placing the asp: label (as previously explained), whose text are assigned dynamically, which are merely used for display purposes.
  That’s it! We have gone through the complete procedure for reading a delimited text file.
  To test this script you will be creating two files: One .aspx file and the other, a .txt file.
  1. Open your notepad
  2. Copy the following complete code
  <%delimit.aspx.
  Now, create a textfile named readtest.txt and copy the following text to that file and save it:
  History of the world, is the history yourselves, what ever you hink that you will be if you think weak, you will be ,if you think yourselves strong you will ,be free and hope for nothing from any one.
  readdelimit.aspx is the source file and readtest.txt is the delimited text file. Dump these files to your wwwroot directory and run readlimit.aspx. That’s it!
  Please add the code. See this link