Get file directory names for only those with creation time is today


#1

Get file names with creation time is today.xaml (8.1 KB)
What I want this automation to accomplish?
I want to move some excel files that get downloaded from a web directly into a user’s downloads. There are two conditions that need to be met before a file should be moved. The first condition is the file names must starts with “Bid+Form” which is working fine. The second condition, which has the error, is to move a file where creation date is today (or if possible 5 minutes after the complete execution of the workflow).
What I have done so far?
The workflow I have so far can move files from downloads directory into a specific folder location (the error comes when I try to add where condition in the assign activity after the file path). I read a couple forum postings, but without success finding a solution. I also looked up some vb.net examples, but I was not able to transfer that knowledge into my workflow.
Thank you so much for your time and your help!


#2

Hi again.

Since it’s vb.net you will need to have Function() to start the .Where.

.Where(Function(f) Directory.GetCreationTime( f ).ToShortDateString = Now.ToShortDateString )

So f can be any word you want to use that represents each item in the array, then you can just use the Directory.GetCreationTime and compare it with Today. You can also add other conditions if you’d like, for example if you want to only use .pdf extensions or if filename contains a word. To add other conditions include AND then the second condition; Path.GetExtension can be used.

Regards.


#3

Hi @ClaytonM
Thanks for your help with this issue!
I am getting a new error that says as shown in the screen shot. fileArray datatype is an array of strings.


#4

Hi @hmheimid,
Can you check the variable declaration like

image

Have to assign the variable like this.
System.IO.Directory.GetFiles(“c:\temp”)

https://msdn.microsoft.com/en-us/library/07wt70x2(v=vs.110).aspx

Regards
Balamurugan


#5

Add .ToArray on the end inside the Assign
I think that’s the issue.

Regards


#6

Thank you ClaytonM ! it works now after I added .ToArray.


#7

Thanks for your suggestion. I just added .ToArray and it worked.
Best regards,