Reputation: 35853
following regular files (date_time.zip) would be generated at 15-min interval in ASP.NET site with Timer.
1027_0100.zip, 1027_011*.zip, 1027_0130.zip, ...
My question is I need a mechanism to restore files which are somehow missed within 3 days, like 1026_0000.zip. What data structure/algorithm would you recommend to use to implement?
PS: I intend to use another Timer to regularly restore missing files.
Thank you!
Upvotes: 0
Views: 75
Reputation: 3399
I'll propose a slightly different solution: rather than querying the disk repeatedly, just use Directory.GetFiles(...) and Linq against that:
string[] files_that_should_exist = YourMethodToGenerateExistingFilenames();
string[] files_in_dir = System.IO.Directory.GetFiles(output_path);
var missing_files = files_that_should_exist.Except(files_in_dir);
foreach(string file in missing_files) YourMissingFileGenerateMethod(file);
Upvotes: 1
Reputation: 25505
Since the naming scheme is know and the where the files are going is know. You simply need to generate what would be the name for each potential file and then check its existence using the System.Io.file.Exists. If that call fails regenerate the file.
Upvotes: 1