Reading From a Delimited file

Posted on 2005-04-21
Last Modified: 2010-04-16
Hi All,

Please help me its Urgent.In Asp.Net using C# iam trying to write from a file delimited by "|".Iam using SqlDataAdapter fillSchema method.The problem is that a text file which has no header,if the same value is repeated in more than one column,the file which i gave for reading is getting concatenated with the cloumn value.

Can anyone please help me out of this.
Question by:osmidhun
    1 Comment
    LVL 96

    Accepted Solution

    You could use a StreamReader, and read in the file on line at a time, and split based on a character:

          System.IO.StreamReader sr = new System.IO.StreamReader(path);

          while (sr.Peek() != -1)

            string input = sr.ReadLine();

            string[] values = input.Split("|".ToCharArray());



    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    745 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

    15 Experts available now in Live!

    Get 1:1 Help Now