Download and replace file

Hi All,

I am downloading file and the files are getting download in c/user/downloads. I want to move the file to the folder and replace the old file .


This is my latest file(OrderMgmtZoneUsageChargesvDGResults8) and I want to replace with the old file (OrderMgmtZoneUsageChargesvDGResults54) in the folder .

@dutta.marina

You can use copy file activity with the required name in destination and use it with over write property

Cheers

Hi @dutta.marina

Move File activity is used to move file from one folder to another folder.
Before doing moving file use the delete file activity to delete the old file.
In your case the last digit only changing then you can use the wild cards when giving the file path and file name in the delete file activity.
image

Note - In Move file activity, If you check the overwrite option if there is any file with the same, it overwrite the file

Hope it helps!!

Hi @dutta.marina

You can get the latest downloaded file by using this expression if the file has a dynamic name and you know the type of file :
Ex:I am getting the latest “.xlsx” file

str_filepath = Directory.GetFiles(folder_path,“*.xlsx”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)

And use move file activity by passing the str_filepath variable and check true for the overwrite box to overwrite the file if already exists in the destination.

Hope it helps.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.