Results 1 to 2 of 2

Thread: Read a text file

  1. #1
    Join Date
    Jun 2009
    Posts
    41
    Rep Power
    0

    Default Read a text file

    Hi. I am last year PC science student. I am learning ASP.net programming language. I am writing one code for read text file in asp.net but it will not work. I also tried unlike code but none of them worked out. If you have any in sequence please let me know that. Thanks in advanced.

  2. #2
    Maxtor Quiney is offline Member
    Join Date
    Jun 2009
    Posts
    46
    Rep Power
    0

    Default

    Refer following program to Read a text file in ASP .NET.We have a textbox with textmode set to MultiLine and a button. On the click event of the button, we require to read the text file. The code within the Click event is shown below.
    Code:
    Sub WriteToFile(sender As Object, e As EventArgs)
    
            Dim fp As StreamReader
    
            Try
                fp = File.OpenText(Server.MapPath(".Upload") & "test.txt")
                txtMyFile.Text = fp.ReadToEnd()
                lblStatus.Text = "File Succesfully Read!"
                fp.Close()
            Catch err As Exception
                lblStatus.Text = "File Read Failed. Reason is as follows 
    
    " & err.ToString()
            Finally
    
            End Try
    
        End Sub

Similar Threads

  1. Can I read the contents of a PHP file
    By Millerjames in forum other peripherals
    Replies: 1
    Last Post: 09-02-2010, 01:36 PM
  2. Can I read the contents of a PHP file
    By PerryCollins in forum Programming
    Replies: 0
    Last Post: 08-09-2010, 01:19 PM
  3. read text file in asp.net
    By ThompsonHarris in forum Programming
    Replies: 1
    Last Post: 04-26-2010, 04:10 PM
  4. read particular Lines of text in c#
    By Davismoore in forum Programming
    Replies: 2
    Last Post: 03-13-2010, 10:35 AM
  5. Replies: 0
    Last Post: 05-06-2009, 10:39 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48