Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6731313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:30:48+00:00 2026-05-26T10:30:48+00:00

Im a beginner, and If statements are my weakness. I have a simple program

  • 0

Im a beginner, and If statements are my weakness. I have a simple program that displays files names that are located in a certain folder. However, some files might have lines that begin with LIFT. I want to catch those files that have that certain line, and display the file name in a different color (preferably red). Here is what I have so far: Any assistance would be greatly appreciated!! Thanks!

public partial class ShippedOrders : System.Web.UI.Page
{
    class Program
    {
        static void Main()
        {
            string[] array1 = Directory.GetFiles(@"C:\Kaplan\Replies\");
            string[] array2 = Directory.GetFiles(@"C:\Kaplan\Replies\", "*.REP");
            Console.WriteLine("---Files:---");
            foreach (string name in array1)
            {
                Console.WriteLine(name);
            }
            Console.WriteLine("---REP Files: ---");
            foreach (string name in array2)
            {
                Console.WriteLine(name);
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:30:49+00:00Added an answer on May 26, 2026 at 10:30 am

    Directory.GetFiles(directoryPath) will return an array of strings listing the file names (full paths) within that directory. You’re going to have to actually open and read each file, using the string array returned. Read each file line by line in a loop and test if any lines begins with “LIFT”.

    Also the way you set up your code-behind for this webpage is funky. You’re declaring a class inside the partial class of the page. Try setting up your code like this:

    public partial class ShippedOrders : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.goFiles();
        }
    
        public void goFiles()
        {
            string[] array1 = Directory.GetFiles(@"C:\Kaplan\Replies\");
            string[] array2 = Directory.GetFiles(@"C:\Kaplan\Replies\", "*.REP");
            System.IO.StreamReader file = null;
            string line = "";
            bool hasLIFT = false;
    
            Response.Write("---Files:---<br/>");
            foreach (string name in array1)
            {
                file = new System.IO.StreamReader(@name);
                while((line = file.ReadLine()) != null)
                {
                    if(line.StartsWith("LIFT"))
                    {
                        hasLIFT = true;
                        break;
                    }
                 }
                 if(hasLIFT)
                 {
                     Response.Write("<span style=\"color:Red;\">" + name + "</span><br/>";
                     hasLIFT = false;
                 }
                 else
                     Response.Write(name + "<br/>";
            }
            //and can do the same for other array
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Absolute beginner question: I have a template file index.html that looks like this: ...
I am a beginner to C#. I am trying to make a simple program
query level: beginner As part of a learning exercise I have written code that
Since I'm beginner in J I've decided to solve a simple task using this
I am an XML beginner, using C# .NET 2.0/Visual Studio 2005. What I have
I'm a beginner in powershell and know C# pretty well. I have this command
I am a beginner SQL user (not formally trained; OJT only) and need some
Hi i am a beginner, and I have this homework for my beginning C
If I have for example two classes A and B , such that class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.