Hi All,
I want to delete all files which are downloaded with today’s date in docx format. What will be the full expression where start date is today’s date and it should delete all files downloaded today
Hi All,
I want to delete all files which are downloaded with today’s date in docx format. What will be the full expression where start date is today’s date and it should delete all files downloaded today
Code this using Studio.
folderPath = "C:\YourDownloadPath"
docxFiles = Directory.GetFiles(folderPath, "*.docx")
For Each file In docxFiles
If File.GetCreationTime(file).Date = DateTime.Now.Date Then
File.Delete(file)
End If
Next
Thanks,
Ashok ![]()
Use the below code in Invoke Code
(Directory.GetFiles("C:\Your\Directory\Path", "*.docx").
Where(Function(f) File.GetCreationTime(f).Date = DateTime.Today).
ToList().
ForEach(Sub(f) File.Delete(f)))
Hope it helps!!
Use below code in Invoke Code:
Directory.GetFiles(path, "*.docx").
Where(Function(f) System.IO.File.GetCreationTime(f).Date = DateTime.Today).
ToList().
ForEach(Sub(f) System.IO.File.Delete(f))
Invoked Code Arguments:
Regards
You can do it the below way also:
=> Use below syntax in Assign:
Assign activity -> fileList = Directory.GetFiles("C:\Your\Directory\Path", "*.docx").Where(Function(f) File.GetCreationTime(f).Date = DateTime.Today).ToArray()
fileList is of DataType Array(System.String)
=> Use For Each loop to iterate through fileList
For Each currentText in fileList
Delete File activity -> pass currentText
End For Each
Regards
Thanks to both of you for the solution
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.