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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:54:14+00:00 2026-05-26T05:54:14+00:00

I am thinking that this is big problem …. I have path like this…C:\restore\restoredb\

  • 0

I am thinking that this is big problem ….

I have path like this…”C:\restore\restoredb\”

In that path i have files like this..

 restore-2011-10-12T17-16-51.zip
 restore-2011-10-11T13-24-45.zip
 restore-2011-05-11T09-45-56.zip
 restore-2011-08-11T09-08-07.zip
 restore-2010-09-11T09-45-12.zip 

I have a form , in that form i have a listbox and combobox(cbrestore)
I have got the combobox items like this …Month, 3 months,6 months,year…

what i want is , if i select the combobox item(month) i want to display the file names which are stored in that folder between these dates (12-10-2011 to 12-09-2011)..

If i select combobox item(3 months) i want to display the file names which are stored in that folder between these dates (12-10-2011 to 12-07-2011)..in listbox

For that i have tried this ….

 private void cbrestore_SelectedIndexChanged(object sender, EventArgs e)
 {
    string fullpathforfiles = @"C:\restore\restoredb\";
    string[] allfiles = Directory.GetFiles(fullpathforfiles);
    foreach (string single in allfiles)
    {
        string filenameonly = Path.GetFileName(single);     
    }
    if (cbrestore.SelectedValue == Daterange.type1)
    { 

    } 
}
struct Daterange 
{
    public const string type1 = "Month";
    public const string type2 = "3 Months";
    public const string type3 = "6 Months";
    public const string type4 = "Year";  

}

I dont know how to extract the exact part in that filename and adding that …
any idea how can i do this .. pls ..

Any suggestions and any code sample snippet would be very greatful to me ….

Many thanks…..

  • 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-26T05:54:15+00:00Added an answer on May 26, 2026 at 5:54 am

    I’d do it like this:

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            List<String> t = Directory.GetFiles(@"C:\Users\justin\Desktop\New folder (2)").ToList();
            List<String> y = new List<string>();
            List<String> u = new List<string>();
            foreach (var zzz in t)
            {
                y.Add(Path.GetFileName(zzz));
            }
    
    
            if (comboBox1.Text == "Month")
            {
                u =
               (from String s in y where ((DateTime.Now.Month - DateTime.Parse(s.Substring(8, 10)).Month) < 1) && (DateTime.Now.Year - DateTime.Parse(s.Substring(8, 10)).Year == 0) select s).
                   ToList();
            }
            else if (comboBox1.Text == "3 Month")
            {
                u =
               (from String s in y where ((DateTime.Now.Month - DateTime.Parse(s.Substring(8, 10)).Month) < 3) && (DateTime.Now.Year - DateTime.Parse(s.Substring(8, 10)).Year == 0) select s).
                   ToList();
            }
            else if(comboBox1.Text == "1 Year")
            {
                u =
               (from String s in y where ((DateTime.Now.Month - DateTime.Parse(s.Substring(8, 10)).Month) < 12) select s).
                   ToList();
            }
            
            listBox1.DataSource = u;
    
        }
    

    The Result is this : enter image description here

    EDIT: Fixed the month problem select you see in the SS and added the year select.

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

Sidebar

Related Questions

I'm working on this application that's sort of like a blog. I'm thinking about
I have the following problem (I think it's well known/standard) that I am thinking
I want to be able to replace style=&quot;STUFF&quot; I keep thinking that this is
Thinking that the answer to this is pretty obvious but here it goes: When
I'm thinking that the reason I can't do this is because it might be
I've written this class that returns feed updates, but am thinking it can be
This is something that comes up so often I almost stopped thinking about it
This question got me thinking about bare strings. When PHP sees a string that's
I have been thinking about this issue and I can't figure it out. Perhaps
I have an ASP.NET web application that I am making and I am thinking

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.