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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

930 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

9 Experts available now in Live!

Get 1:1 Help Now