ASP.NET
  Home arrow ASP.NET arrow Page 5 - Reading a Delimited File Using ASP.Net and...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Reading a Delimited File Using ASP.Net and VB.Net
By: G Ajaykumar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 106
    2003-10-15

    Table of Contents:
  • Reading a Delimited File Using ASP.Net and VB.Net
  • Usage
  • Example Code
  • Example Code, Cont'd
  • Code Explanation
  • Output

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Reading a Delimited File Using ASP.Net and VB.Net - Code Explanation


    (Page 5 of 6 )

    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

    <%--
     Beginning of script Reading a delimited text file written by G.Ajaykumar<
    ajaykumar_g@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 readdelimit.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 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.

    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!

    More ASP.NET Articles
    More By G Ajaykumar


       · hi!nice code.i have a little problem as i m using ur code but if my .txt file...
       · This was an excellent article. I found it very logically laid out and clearly...
     

    ASP.NET ARTICLES

    - How Caching Means More Ca-ching, Part 2
    - How Caching Means More Ca-ching, Part 1
    - Reading a Delimited File Using ASP.Net and V...
    - What is .Net and Where is ASP.NET?
    - An Object Driven Interface with .Net
    - Create Your Own Guestbook In ASP.NET
    - HTTP File Download Without User Interaction ...
    - Dynamically Using Methods in ASP.NET
    - Changing the Page Size Interactively in a Da...
    - XML Serialization in ASP.NET
    - Using Objects in ASP.NET: Part 1/2
    - IE Web Controls in VB.NET
    - Class Frameworks in VB .NET
    - Cryptographic Objects in C#: Part 1
    - Sample Chapter: Pure ASP.Net







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek