Delete file (By short solution)

I want to delete file in folder DTA ( Except in folder report)

image

Please guide me about it.

@fairymemay

Use Assign activity and write as StringVariable = Directory.GetFiles(FolderPath)

Now use For Each Activity, change the Type Arguments to String and pass the StringVariable

Inside that place Delete file activity, FileName as Item.ToString

Hope this will help you

Thanks

1 Like

@fairymemay

Another way use Invoke Code and write as below

Array.ForEach(Directory.GetFiles(FolderPath), Sub(File) File.Delete(File))

Hope this may help you

Thanks

@Srini84 I use this. But show error as below.

How to solve it?

@fairymemay

Oh ok, can you place X in place of file and check

Thanks

@fairymemay

Try as below

Array.ForEach(Directory.GetFiles(FolderPath), Sub(X) File.Delete(X))

Thanks

@Srini84 Same error.

@fairymemay

Okay, It think the same namespace is clasing with the Microsoft Sharepoint also

So put as below

Array.ForEach(Directory.GetFiles(FolderPath), Sub(X) System.IO.File.Delete(X))

Thanks

Use delete file activity and pass that file path.

1 Like

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