How to delete old files

Hi,

I want to get the creation date of a file so I can delete them if they are older than a x-amount of days. I saw other posts about this on the forum and people posted a xaml file as a solution. Those are old solutions and can’t be opened with the new version of studio anymore. So I would like to know how to do this.

Thanks!

@Yagsinats Get all the files into array by using directory.getfiles(dirpath)
Loop over array of files and compare the loop item(file) creation date with your x amount of time if it is less than then delete the file

I get that. But how do I get the creation date of the file?

1 Like

@Yagsinats
File.GetCreationTime(filepath)

1 Like

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