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
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
159 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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