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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:57:51+00:00 2026-05-26T00:57:51+00:00

I am populating a datagrid control using files in a specified path (DirectoryInfo). I

  • 0

I am populating a datagrid control using files in a specified path (DirectoryInfo).
I would like to filter the files based on a user specified date range (start date & end date).

While search S/O, I found this post, but I am getting an error on DateComparer (“‘DateComparer’ is a type and cannot be used as an expression.”)

Any other suggestions on how to filter by date?

Here is my code:

        Dim dirInfo As New DirectoryInfo(strDirectoryPath)
        Dim dStartDate As DateTime = "03/01/2011"
        Dim dEndDate As DateTime = "6/30/2011"
        Dim Files As FileInfo = dirInfo.GetFiles().Where(Function(Files) Files.CreationTime >= (dStartDate) AndAlso Files.CreationTime <= dEndDate)

            datagrid.DataSource = Files
            datagrid.DataBind()
  • 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-26T00:57:52+00:00Added an answer on May 26, 2026 at 12:57 am
    DateTime your_start_date = new DateTime(2011,1,1);
    DateTime your_end_date = new DateTime(2011,10,1);
    FileInfo [] files = new DirectoryInfo(@"c:\").GetFiles().Where(x=>x.CreationTime>=(your_start_date) && x.CreationTime<=(your_end_date)).ToArray();
    
    foreach(var item in files)
    {
     Console.WriteLine(item.Name);
    }
    

    On my test case prints out:

    copy_one.jpg
    copy_one_one.jpg
    copy_one_one_one.jpg
    hiberfil.sys
    one.jpg
    pagefile.sys
    PcapDotNet.snk
    

    UPDATE (VB version):

    Dim your_start_date As New DateTime(2011, 1, 1)
    Dim your_end_date As New DateTime(2011, 10, 1)
    Dim files As FileInfo() = New DirectoryInfo("c:\").GetFiles().Where(Function(x) x.CreationTime >= (your_start_date) AndAlso x.CreationTime <= (your_end_date)).ToArray()
    
    For Each item As FileInfo In files
        Console.WriteLine(item.Name)
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control called HomePage.xaml . I'm creating a model instance (using
Instead of populating the BitmapData class from an IMAGE. I would like to (within
When populating my treeview I would like to use the same images that I
I'm populating a datagrid using Linq--standard kind of stuff (code below). For some reason
I am populating 3 columns of my datagrid using a simple XML file. The
im populating the data in the combo box using dataset tables...with some table name..now
I am populating a DataGridView control on a Windows Form (C# 2.0 not WPF).
I'm working on populating a combobox in visual studio 2005 using vb and I'm
I m populating data for different entities into set of lists using generic lists
I am populating a JComboBox (using addItem() ) with all the elements of a

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.