Results 1 to 2 of 2

Thread: read text file in asp.net

  1. #1
    ThompsonHarris is offline Senior Member
    Join Date
    Dec 2009
    Posts
    255
    Rep Power
    3

    Default read text file in asp.net

    Hi. I am learning ASP.net programming language. I want to know that how to read text file in asp.net. I tried different code but none of them worked out. If you have any in solution please let me know that. Thanks in advanced.

  2. #2
    GonzalezBrown is offline Senior Member
    Join Date
    Dec 2009
    Posts
    260
    Rep Power
    3

    Default

    The given code will help us to read the file content and using StringBuilder object. Add System.IO namespace for this code to work.

    Code:
    string root = Server.MapPath("~");
    string Template = root +"\test.txt";
    StringBuilder line = new StringBuilder();
    using (StreamReader rwOpenTemplate = new StreamReader(Template))
    {
    while (!rwOpenTemplate.EndOfStream)
    {
    line.Append(rwOpenTemplate.ReadToEnd());
    }
    }

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 a text file
    By Alexander Roads in forum Programming
    Replies: 1
    Last Post: 04-12-2010, 12:13 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