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 would like to know what the best practice for populating a business object
I have a user control called HomePage.xaml . I'm creating a model instance (using
I'm populating a datagrid using Linq--standard kind of stuff (code below). For some reason
Does anyone have an example of using of populating a YUI DataTable with a
I am using GridView in my application for populating datas. Is there any easy
I am currently building a .Net userform using C# and I am populating it
Initialization would include creating all the required tables, constraints and populating the tables. edit:
I am using a DataGridView control in my app at the moment and I
I am populating a DataGrid with the following LINQ code : Dim myClients =
I am populating a DropDownList control as follows - public partial class UserControls_PMS_Send2DeliveryTeam :

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.