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
Try the below Activity
Try below expression.
strFileDate = New FileInfo("File path").GetLastWriteTime.ToString("dd/MM/yyyy")
Check the workflow below:
This workflow will search for the newest file, and check if the file was created today or not.
Forum_NewFile.xaml (5.6 KB)
Hi, Thanks for the reply, these are not working for me. any alternative??
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.
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.
Hope the below steps would help you resolve this
- 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
Then use a FOR EACH activity and pass the above array as input and change the type argument as string
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
- 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
Simply, your can use try catch to care that