I have a workflow which downloads the attachment from mail, and saves it in a new folder everyday.
Now i need to open the folder that is created today and read the data in the file.
If someone else creating the folder then you can get the directories created today using the below query,
Directory.GetDirectories("yourdirectorypath").[Select](Function(d) New DirectoryInfo(d)).Where(Function(d) d.CreationTime.Date.Equals(Datetime.Now.Date)).ToList()
If you want to get the directory based on modified time, then change the “CreationTime” to “LastWriteTime”.
If your bot only creating the folder and it will be in the same naming format then we can go with @Boaepa post in this thread.
If you are getting aggregate exception, then it means the file is not available there.
Check whether the file available in the folder where you are trying to read it from the code.
Print the file path from the code and check the same.
Directory.GetFiles(“C:\Users\XXXXX\Documents\UiPath\Settlement_Report\Settlement Report\Settlement - ” & DateTime.Now.ToString(“ddMMyyyy”) ,“*.txt”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).ToList()
Now i have to read the file using notepad ++ due to format issue. I tried read text activity and start process activity, but couldn’t achieve what i need.
That does not matter if you want to read the text alone form that file, Please confirm what you are trying to read from this file and what you have to do further with that
Okay, so you can read the text file using read text file activity, then split it with Environment.NewLine. After that in your Send Mail, make that as html mail body and form this string with to form the same table as you shown in the notepad++ output.