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 3403666
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:17:20+00:00 2026-05-18T05:17:20+00:00

I have a C# console program which main functions should let a user grep

  • 0

I have a C# console program which main functions should let a user grep lines / columns from a log text file.

An Example within the text file the user wishes to grep a group of all the related lines starting from a particular date etc. “Tue Aug 03 2004 22:58:34” to “Wed Aug 04 2004 00:56:48”. Therefore after processing, the program would then output all the data found within the log text files between the 2 dates.

Could someone please advise on some codes that I could use to grep or create a filter to retrieve the neccessary text/data from the file? Thanks!

C# Program Files:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

namespace Testing
{
class Analysis
{
    static void Main()
    {
        // Read the file lines into a string array.
        string[] lines = System.IO.File.ReadAllLines(@"C:\Test\ntfs.txt");

        System.Console.WriteLine("Analyzing ntfs.txt:");

        foreach (string line in lines)
        {
            Console.WriteLine("\t" + line);

            //  ***Trying to filter/grep out dates, file size, etc****
            if (lines = "Sun Nov 19 2000")
            {
                Console.WriteLine("Print entire line");
            }
        }

        // Keep the console window open in debug mode.
        Console.WriteLine("Press any key to exit.");
        System.Console.ReadKey();
    }
}
}

Log Text File Example:

Wed Jul 21 2004 16:58:48   499712 m... r/rrwxrwxrwx 0        0        8360-128-3 
C:/Program Files/AccessData/Common Files/AccessData LicenseManager/LicenseManager.exe

Tue Aug 03 2004 22:58:34    23040 m... r/rrwxrwxrwx 0        0        8522-128-3 
C:/System Volume Information/_restore{88D7369F-4F7E-44D4-8CD1-
F7FF1F6AC067}/RP4/A0002101.sys

23040 m... r/rrwxrwxrwx 0        0        9132-128-3 
C:/WINDOWS/system32/ReinstallBackups/0003/DriverFiles/i386/mouclass.sys

23040 m... r/rrwxrwxrwx 0        0        9135-128-4 C:/System Volume 
Information/_restore{88D7369F-4F7E-44D4-8CD1-F7FF1F6AC067}/RP4/A0003123.sys

23040 m... r/rrwxrwxrwx 0        0        9136-128-3 
C:/WINDOWS/system32/drivers/mouclass.sys

Tue Aug 03 2004 23:01:16   196864 m... r/rrwxrwxrwx 0        0        4706-128-3 
C:/WINDOWS/system32/drivers/rdpdr.sys

Tue Aug 03 2004 23:08:18    24960 m... r/rrwxrwxrwx 0        0        8690-128-3 
C:/WINDOWS/system32/drivers/hidparse.sys
  • 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-18T05:17:20+00:00Added an answer on May 18, 2026 at 5:17 am

    Well, as a quick fix for the specific example:

    if (line.StartsWith("Sun Nov 19 2000"))
    {
        Console.WriteLine(line);
    }
    

    You could use Contains to find a substring within the line.

    Note that loading the whole file in an array won’t scale well for very large logs. We can look into fixing that if it’s an issue for you – but let’s take things slowly 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little c# console program that outputs some text using Console.WriteLine. I
I have a console program written in C# that I am using to send
I have a C#/.NET program that can run both as a console application and
I have created a console test application which creates, an object & calls 2
I have a program that calls a Filewatcher function, like this Main() { watch();
I have a Java console application that is launched from a batch script in
In a C# console application, is there a smart way to have console output
I have a console app that needs to display the state of items, but
I have a console application that will be kicked off with a scheduler. If
I have a Console application hosting a WCF service. I would like to be

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.