read flat file

Posted on 2007-08-09
Last Modified: 2010-04-15
I am trying to read a fixed width flat file from C# code, any ideas ?
Question by:saswati_m
    LVL 13

    Expert Comment

    if you mean a text file:

    string str = File.ReadAllText("File_Path");
    LVL 2

    Accepted Solution

    Additionally, you could read it line by line:
    StreamReader sr = File.OpenText(filename);
    for (; ; )
           string line = sr.ReadLine();
           if (line == null)
                  break; // end of file
    LVL 1

    Expert Comment

    --------------------------------------------------------------------------------------------------------------------------------------------------      StreamReader sr=new StreamReader(FilePath);
          string Detail=String.Empty;
    LVL 96

    Expert Comment

    by:Bob Learned
    Dog pile!!!

    string[] lines = File.ReadAllLines("File_Path");


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    This is an explanation of a simple data model to help parse a JSON feed
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now