?
Solved

How to read each line of a text file from a C# web app

Posted on 2008-10-18
3
Medium Priority
?
877 Views
Last Modified: 2012-05-05
I am using a ajax enabled asp 2.0 page in VB.net 2005 page in C#

I need to have my program to read each line of a text file and after that line store that information into a variable then continue to the next line and repeat. please help thanks!
0
Comment
Question by:Figle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:brenkehoe777
ID: 22749843
Try this:
StreamReader sr = new StreamReader("c:\\blob.txt");
 
            while (!sr.EndOfStream)
            {
                string line = sr.ReadLine();
            }

Open in new window

0
 

Author Comment

by:Figle
ID: 22750389
sorry about the delayed response, work is crazy today and thanks but this only puts the last thing in the text file into the variable, thats where i am stuck at. I am going to post with a better idea of what i need.

0
 
LVL 16

Accepted Solution

by:
CuteBug earned 2000 total points
ID: 22750623
use the following code

using System.IO;

string[] data = File.ReadAllLines("path_to_file");
foreach (string s in data)
{
     StoreMyData(s);
}
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

770 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