Until here everything is fine. My problem now is, I have to alert the department that this folder was created by email. And inside that email i have to provide the direct path last created folder.
Did anyone achieve this in the past?
I just need to have some opinions or tips in how to achieve this.
Could you confirm if all these folders will always be created in the same directory?
If yes, then to go for recently created folder, you can fetch the folder details basis recent timestamp and then mail those details.
Lets say if for today’s run, some exceptions happened and no new folder was created so last folder in the directory may be from last day. In that case, you may want to add few more conditions wrt date check for that particular day.
@Andre_Vieira - I will give your couple of codes, please see which one suits you…
This will get recent folder created on that day…because it will check createtime equals today
Directory.GetDirectories("YourFolderName").Where(function(x) new FileInfo(x).CreationTime.date = now.date).OrderByDescending(function(x) new fileinfo(x).CreationTime).First
This will get you the recent folder created in the given path
Directory.GetDirectories("YourFolderName").OrderByDescending(function(x) new fileinfo(x).CreationTime).First
Note: None of the above code will look for subdirectories, if would like just include “SearchOption.AllDirectories”. Also, above codes will fetch the files based on the createtime, if you want lastwritetime, replace the createtime with LastWriteTime.