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

Suggested Solutions

Title # Comments Views Activity
Visual Studio Publish Web Configuration does not contain Release 5 33
Connection String 16 61
Where can I ask about my ASP.NET MVC project? 6 38
ASP.NET MVC 2 32
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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

831 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