Hello!
I have a directory, and would like to get the latest created folder’s creation date from that directory. Can you help me with this issue?
Thanks in advance!
P1
Hello!
I have a directory, and would like to get the latest created folder’s creation date from that directory. Can you help me with this issue?
Thanks in advance!
P1
please try this:
DirectoryInfo latestfolder = new DirectoryInfo(path).GetDirectories("*",SearchOption.AllDirectories).OrderByDescending(function(d) d.CreationTime).First();
it will return the latest created folder(last modified) directory.
and let me know
and to get folder name and with date of creation see the attached sample.
Reference: latestdirdate.xaml (5.2 KB)
Thank you, works perfectly!
P1
One more question, how is it possible to get the latest created folder instead of last modified? Last modified works as well, but my process would be more stable if i could implement that instead of the modification time.
Thanks!
my bad, ty!
Yes please check.the updated post and example.
Hey guys, thanks for that trail, it has been super helpful! However I have a weird problem, if I use what is in the automation above, I get a message with a string containing the file name, however if I want to use file.Name as attachment in an outlook message if sometimes works and somethimes throws an error:
"Main has thrown an exception
Source: Send Outlook Mail Message
Message: Cannot find this file. Verify the path and file name are correct.
Exception Type: FileNotFoundException
System.IO.FileNotFoundException: Cannot find this file. Verify the path and file name are correct.
at UiPath.Mail.Activities.SendMailActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)"
I don’t know why and how to fix this Can you help, please?