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

  • Home
  • SEARCH
  • 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 7525909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:41:05+00:00 2026-05-30T03:41:05+00:00

I have a FileInfo array, which returns me 15 files and one .zip folder.

  • 0

I have a FileInfo array, which returns me 15 files and one “.zip” folder. I basically need to try and somehow filter this “.zip” file out of the array. Any help would be much appreciated, but it seems I am just banging my head against a brick wall! Here is the code that I am trying to impliment this into;

public List<FileInfo> getInfo(bool recursive, int ageDays)
{
  //Declarations
  DirectoryInfo di = new DirectoryInfo(CurrentFilePath);
  FileInfo[] fi = new FileInfo[0];
  List<FileInfo> results = new List<FileInfo>();
  fileResults = new List<Files>();
  DateTime ageInDays = DateTime.Now.AddDays(-ageDays);

  //Checks for recursive search
  if (recursive)
  {
    try
    {
      fi = di.GetFiles("*.*", SearchOption.AllDirectories);
    }
    catch (Exception)
    {
    }
  }
  else
  {
    try
    {
      fi = di.GetFiles();
    }
    catch (Exception)
    {
    }
  }

  for (int i = 0; i < fi.Length; i++)
  {
    if (fi[i].LastWriteTime < ageInDays)
    {
      results.Add(fi[i]);
    }
  }
  return results;
}

Thanks in advance!

  • 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-30T03:41:07+00:00Added an answer on May 30, 2026 at 3:41 am

    Have you tried:

    for (int i = 0; i < fi.Length; i++)
            {
                if (fi[i].LastWriteTime < ageInDays && fi[i].Extension != ".zip")
                {
                    results.Add(fi[i]);
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a fileinfo array which loads jpegs from a folder. When I add
Basically, I have this code: DirectoryInfo dir = new DirectoryInfo(@\\MYNETWORK11\ABCDEFG\ABCDEFGHIJKL\00806\); FileInfo[] files = dir.GetFiles(200810*);
I have some code which ignores a specific exception. try { foreach (FileInfo fi
I have a FileInfo array with ~200.000 File Entries. I need to find all
I have noticed this piece of code: FileInfo[] files =new DirectoryInfo(@C:\).GetFiles(); What is the
I have a simple application with the following code: FileInfo[] files = (new DirectoryInfo(initialDirectory)).GetFiles();
I have that method that counts files in a certain folder: private void countfiles(string
I have a filename ( C:\folder\foo.txt ) and I need to retrieve the folder
I have a solution folder in which I have collect all the .dll's and
I have a controller that returns a list of files in a directory using

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.