I have four input files as shown below in the input folder, i need to get the each input file based on the timing.
For example if i run the bot at 11 AM that time it should get the file of 11 AM , and if i run the bot at 4 pm it should get the file of 4 PM one. Please help me to get this
Try this:
Assign -> filteredFile = Directory.GetFiles("C:\Path\To\Input\Folder").Where(Function(file) Path.GetFileName(file).Contains(DateTime.Now.ToString("h tt", System.Globalization.CultureInfo.InvariantCulture))).FirstOrDefault()
Regards
if i run the bot between 10 AM to 01 PM it should pick 11 AM file,
and if run the bot between 01 PM to 04 PM it should pick 01 PM file,
if i run between 04 PM to 07 PM then 07 PM file should get and
last if i rub between 07 PM to 10 PM it should pick 07 PM file. can u provide solution in that way
Try this way then:
Assign Activity -> selectedFile = String.Empty
Assign Activity -> files = Directory.GetFiles("C:\Path\To\Input\Folder")
If
DateTime.Now.Hour >= 10 AndAlso DateTime.Now.Hour <= 13
Then
Assign -> selectedFile = files.Where(Function(file) Path.GetFileName(file).Contains("11 AM")).FirstOrDefault()
Else If
DateTime.Now.Hour >= 13 AndAlso DateTime.Now.Hour <= 16
Then
Assign -> selectedFile = files.Where(Function(file) Path.GetFileName(file).Contains("1 PM")).FirstOrDefault()
Else If
DateTime.Now.Hour >= 16 AndAlso DateTime.Now.Hour <= 19
Then
Assign -> selectedFile = files.Where(Function(file) Path.GetFileName(file).Contains("4 PM")).FirstOrDefault()
Else If
DateTime.Now.Hour >= 19 AndAlso DateTime.Now.Hour <= 22
Then
Assign -> selectedFile = files.Where(Function(file) Path.GetFileName(file).Contains("7 PM")).FirstOrDefault()
End If
Regards
I am able to get the solution, Thank you
In remote does your file get downloaded everyday. What is the exact process you are doing?
Regards
I am able to get the solution, Thank you
May be you can store the files that are downloaded today in a array variable and use the Else If conditions
Assign todayFiles = Directory.GetFiles("C:\Path\To\Your\Folder")
.Where(Function(file) File.GetLastWriteTime(file).Date = DateTime.Today.Date)
.ToArray
The above syntax will get the files that are downloaded in the present day after that use the same Else If conditions and try.
Regards
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
