Clear %Temp% files using Uipath

Hi,
I have data that gets stored in %Temp% files everyday.
I have to clear it everyday and I have to make a code that deletes the file.
How to do it?

Hi @Kunal_Jain

Please check on this

Cheers!!

Hi @lrtetala
I have tried this but it doesn’t work.
All the files are not getting deleted.
Thanks!!

@Kunal_Jain

Hi @lrtetala
No this is giving me the error.
Thanks

@Kunal_Jain

How about the following?

tempFolderPath = Environment.GetEnvironmentVariable("Temp")

tempFiles = Directory.GetFiles(tempFolderPath)

Hi @Kunal_Jain

→ You can use the For each file in folder activity to iterate the files in the folder.
→ Copy the folder path of Temp from your local folder and paste it in the In folder option in For each file in folder activity.

My Temp folder path look likes below -
"C:\Users\MKANAKA1\AppData\Local\Temp"

→ Insert the delete file activity inside the for each activity.

Check the below workflow for better understanding,

Hope it helps!!

Hi @rikulsilva
We have to delete temp files for several users using one main account that is accessible to all.
How to delete all the temp files for all users using main account?
Thanks in advance
We have to use config file for deleting the users.

@Kunal_Jain

Use Delete activity instead and check Continue On Error

This way if some error occur when trying to delete a file the execution continues to the next one without break

@rikulsilva
Thanks for the help!!

1 Like

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