I am trying to delete all file which are more than 7 days old. Its not working .
My sequence is below
The file modified format is -
Sequence
I am trying to delete all file which are more than 7 days old. Its not working .
My sequence is below
The file modified format is -
Sequence
Hi
Hope the below steps would help you resolve this
arr_filepath = Directory.GetFiles(“yourfolderpath”)
Where arr_filepath is a variable of type array of string
Now use a FOR EACH activity and pass above array variable as input and change the type argument as string
Inside the loop use a IF activity with condition like this
new System.IO.FileInfo(item).CreationTime > DateTime.Now.AddDays(-7)
If this condition is true it goes to THEN block. Where use a DELETE FILE activity and pass filepath as item.ToString
Cheers @ravindar.singh
Thanks Palaniyappan.
from what I got I am already trying your method. I am deleting files from share point.
Atlast with if activity lets not compare with string
Remove .ToString at both end between > symbol
It has to be like comparing datetime and not the strings
Cheers @ravindar.singh
@Palaniyappan
I found a solution not a great one but it does work lol.
Using split and then converting yo datetime
The reason it’s not working is because LastModifiedDateTime is of type DateTimeOffset. You can try to convert it to DateTime first:
DriveItemFiles.LastModifiedDateTime.LocalDateTime < Now.Add(-7)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.