// Show the OpenFileDialog. DialogResult result = ofd.ShowDialog(); if (result == DialogResult.OK) { string fullPath = ofd.FileName; string directory; directory = fullPath.Substring(0, fullPath.LastIndexOf('\\')); textBox1.Text = directory; DateTime.Now.ToString("yyyyMMdd"); // ??? i don't know how i can query the date range so that it will be considered in my code if (File.Exists(fullPath)) { string[] AllZipFiles = Directory.GetFiles(directory,"*.zip",SearchOption.AllDirectories); // Get all files from the folder foreach (string zipfile in AllZipFiles) { this.comboBox1.Items.Add(zipfile); // it' working but with all the fullpath, but i only want to get the filename like test.zip } } else MessageBox.Show("There is not Zip File in this Folder"); }
string path = @"D:\Audiobooks"; //change initial path to your needs string filter = "*.zip"; DateTime startdate = new DateTime(2012,1,1); //change dates to your needs DateTime enddate = new DateTime(2016,12,31); List<string> files = Directory.EnumerateFiles(path, filter, SearchOption.AllDirectories) .Where(x=>File.GetLastWriteTime(x)>=startdate && File.GetLastWriteTime(x)<=enddate) .Select(x=>Path.GetFileName(x)) .ToList(); foreach(string zipfile in files) { combobox1.Items.Add(zipfile); }
startdate
enddate
DateTime startdate = DateTimePicker1.Value;
using (System.IO.Compression.ZipArchive archive = System.IO.Compression.ZipFile.OpenRead(fullPath)) { foreach (System.IO.Compression.ZipArchiveEntry entry in archive.Entries) { Console.WriteLine("{0}", entry.FullName); } archive.Dispose(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)