Get file saved today

Hi, i have to copy the file and paste in a folder, Now I want to check whether the file is already copied or not for that day. The file name is not having current date. If there is any error in the process and if we rerun the process the dates will increase by one day, which is not correct. I am using file exist activity, but not able to get how to check the already copied file. Can anyone help

Hi @nagini.pragna

Try the below Activity
image

Regards
Sudharsan

1 Like

@nagini.pragna

Try below expression.

           strFileDate = New FileInfo("File path").GetLastWriteTime.ToString("dd/MM/yyyy")
1 Like

Check the workflow below:

This workflow will search for the newest file, and check if the file was created today or not.

XAML file:
Forum_NewFile.xaml (5.6 KB)

Best,
Charbel

1 Like

Hi, Thanks for the reply, these are not working for me. any alternative??
Thanks

what is the error or issue you are facing in trying the Directory function method suggested by Charbel?

We’ll appreciate if you give a try and then come back with updated information so as to lessen the post’s length and close the thread sooner. :slight_smile:

Charbel method is creating new empty file, if no file is copied for that day. i have used the copy activity in else statement then it is giving me this error.

Hi

Hope the below steps would help you resolve this

  1. Use a assign activity to get all the filepath to be copied from a folder

arr_filepath = Directory.GetFiles(“yourfolderpath”)

Where arr_filepath is a variable of type array of string

  1. Then use a FOR EACH activity and pass the above array as input and change the type argument as string

  2. Inside the loop use a PATH EXISTS activity and choose File as path type
    And mention like this in the input
    “Your new folder path”+”\”+Path.GetFileName(item.ToString)

This will check whether the file we copied is there already in the new folder where we are going to paste the file

Get the Boolean output as bool_exists

  1. Now inside the same loop use a IF condition and mention like this

bool_exists = True

If true Then it means the file already exists
If false it goes to ELSE block where keep you COPY FILE activity and mention as item.ToString in FROM property and your new folder path in TO property

Hope this would help you resolve this issue

Cheers @nagini.pragna

1 Like

Simply, your can use try catch to care that

1 Like