How to check and delete files of xlsx format from a folder

Hello ,
I need to check if there is any xlsx files present in folder and delete it.

How can I achieve it?

1 Like

Hi @Karan28
StrArray=Directory.GetFiles(“your file path”,“xlsx”)
use for each item in strarray
Use Path exists
then use delete file

Thanks
Ashwin S

1 Like

HII
hope these steps would help you resolve this
–use assign activity and mention like this
arr_filepath = Directory.GetFiles(“yourfolderpath”,"*.xlsx")
where arr_filpath is a variable of type array of string

—and pass this variable to arr_filepath to a FOR EACH activity where change the type argument as string in the property panel of for each loop

–inside the loop use DELETE activity and mention the input as item.tostring

Cheers @Karan28

@Karan28

Try below expression to find excel files.

    excelFiles [] = Directory.GetFiles("Folder path","*.xlsx")

      IF excelFiles.Count > 0 
      Then use ForEach loop to iterate files and inside that use Delete activity to delete file
1 Like

hey lakshman , yes your solution worked just like @Palaniyappan

thankyou so much :slight_smile:
I dont know whose comment I should mar as solution hehe

2 Likes

You guys decide!

1 Like

@Karan28

Glad to help you and happy that our solution got worked. You can mark any one solution and that is not a problem. Infact he gave reply first and you can mark his post as solution.

1 Like

Thankyou Laksham , All the best

2 Likes

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