Solved

How would you write a loop routine for a C# console application using Visual Studio 2005 to assign the value in positioins 87 to 95 to a string variable named strAccounts?

Posted on 2012-03-22
1
156 Views
Last Modified: 2012-03-26
I am developing a C# console application using Visual Studio 2005. How would you write a loop routine to read the records in a text file 1 at a time and assign the value of positions
87 to 95 to a string variable titled strAccount while there are records in the text file? The text file resides at C:\files\test.txt.

While (! EOF)
{    
     strAccount = ???
     peformRoutineXXX
}
0
Comment
Question by:zimmer9
1 Comment
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 37755064
Assuming a "record" is simply one line in the text file...something like:
            string line = "";
            string strAccount = "";
            string FileName = @"C:\files\test.txt";
            StringReader SR = new StringReader(FileName);
            while (SR.Peek() != -1)
            {
                line = SR.ReadLine();
                if (line.Length >= 95)
                {
                    strAccount = line.Substring(86, 9); // zero based index
                    peformRoutineXXX(strAccount);
                }
            }
            SR.Close();

Open in new window

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

10 Experts available now in Live!

Get 1:1 Help Now