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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:24:18+00:00 2026-06-14T04:24:18+00:00

Is there a way to get all the files (last modified on a specific

  • 0

Is there a way to get all the files (last modified on a specific date), and save them into a new folder (with the name of the specific date).

Example files:

Inside C:/

Image File     Date Modified

Image001.jpg   11/12/2012
Image002.jpg   11/12/2012
Image003.jpg   11/13/2012
Image004.jpg   11/12/2012

Output should be:

C:/20121112/

Image001.jpg
Image002.jpg
Image004.jpg  

C:/20121113

Image003.jpg

I am currently using the syntax below:

var mydirectory = new DirectoryInfo("C:/");
DateTime from_date = DateTime.Now.AddDays(-1);
DateTime to_date = DateTime.Now;
var files = directory.GetFiles()
  .Where(file=>file.LastWriteTime >= from_date && file.LastWriteTime <= to_date);

But I don’t how save to save var files to another folder 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-06-14T04:24:19+00:00Added an answer on June 14, 2026 at 4:24 am

    Perhaps:

    var files = Directory.EnumerateFiles(path, "*.jpg", SearchOption.TopDirectoryOnly)
                         .Select(fn => new FileInfo(fn));
    var fileDateGroups = files.GroupBy(fi => fi.LastWriteTime.Date);
    foreach (var dateGroup in fileDateGroups)
    {
        string dir = Path.Combine(@"C:\", dateGroup.Key.ToString("yyyyMMdd"));
        Directory.CreateDirectory(dir);
        foreach (var file in dateGroup)
        {
            string newPath = Path.Combine(dir, file.Name);
            File.Copy(file.FullName, newPath, true);
        }
    }
    

    Edit: If you want to search for multiple file extensions you need to filter them manually:

    var allowed = new[]{ ".png", ".jpg" };
    var files = Directory.EnumerateFiles(path, "*.*", SearchOption.TopDirectoryOnly)
                         .Where(fn => allowed.Contains(Path.GetExtension(fn)))
                         .Select(fn => new FileInfo(fn));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to get all the querystring name/value pairs into a collection?
Is there some way to get a distinct list of file extensions on all
Is there a way to get all versions of list item(s) using a CAML
Is there a way to get all possible values from a MySQL enum column?
In Java, is there any way to get (catch) all exceptions instead of catching
Is there a way I can ask Visual source safe to get all the
I was wondering if there was a quick way to get all of an
Is there a way to get a list of all open sockets ( socket
Is there a way to get a total count of all webs in a
Is there a simple way to get array of all index paths for the

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.