To test this script you will be creating two file one .aspx file and the other .txt file
- Open your notepad
- Copy the following complete code
<%--
Beginning of script Reading a delimited text file written by G.Ajaykumar<ajaykumar_g AT hotmail.com>--%>
<%@Import Namespace="System.IO"%>
<script language="vb" runat="server">
Sub page_load(Sender As Object,e As EventArgs)
Dim filetoread as string
filetoread=server.mappath("readtest.txt")
dim filestream as StreamReader
filestream = File.Opentext(filetoread)
Dim readcontents as String
readcontents = fileStream.ReadToEnd()
Dim textdelimiter as String
textdelimiter = ","
Dim splitout = Split(readcontents,textdelimiter)
lblplaintext.text = readcontents & "<br>"
dim i as integer
for i=0 to Ubound(splitout)
lblsplittext.Text &= "<b>Split </b>" & i+1 & ") " & splitout(i)& "<br>"
next
filestream.Close()
End Sub
</script>
<asp:label align="center" ForeColor="Maroon" Font-Names="Arial" BackColor="LemonChiffon" BorderColor="#0000C0" runat="server" id="lbldisplay" Font-Name="Verdana" text="Reading a delimited text file using ASP.NET/VB.NET coded by G.Ajaykumar" /><br />
<br /><br /><b>Plain Output</b><br />
<asp:label runat="server" id="lblplaintext" Font-Name="Verdana" /><br />
<b>Split Output</b><br />
<asp:label runat="server" id="lblsplittext" Font-Name="Verdana" />
<%-- End of script--%>
Save the file as readdemilit.apx
- 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 of few men who had faith in themselves, that faith calls out the divinity, with in, you can do anything you fail only when you do not strive sufficiently to manifest the infinite power, if you have faith in all the three hundred and thirty millions, of your mythological gods and in all the gods which foreign has now and gain faith, in yourselfs,what ever you hink that you will be if you think weak weak, you will be,if you think yourselves strong strong you will ,be free and hope for nothing from any one.
readlimit.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!
Your output should look like the following
Plain Output
History of the world, is the history of few men who had faith in themselves, that faith calls out the divinity, with in, you can do anything you fail only when you do not strive sufficiently to manifest the infinite power, if you have faith in all the three hundred and thirty millions, of your mythological gods and in all the gods which foreign has now and gain faith, in yourselfs,what ever you hink that you will be if you think weak weak, you will be,if you think yourselves strong strong you will ,be free and hope for nothing from any one.
Delimited Output
Split 1) History of the world
Split 2) is the history of few men who had faith in themselves
Split 3) that faith calls out the divinity
Split 4) with in
Split 5) you can do anything you fail only when you do not strive sufficiently to manifest the infinite power
Split 6) if you have faith in all the three hundred and thirty millions
Split 7) of your mythological gods and in all the gods which foreign has now and gain faith
Split 8) in yourselfs
Split 9) what ever you hink that you will be if you think weak weak
Split 10) you will be
Split 11) if you think yourselves strong strong you will
Split 12) be free and hope for nothing from any one.