Temp files interfering with for each file in directory

Hello there.

I had this XAML where I have a for each files in a directory, and it worked perfectly as of yesterday, the loop started to take the ~$ files, these are temp files, Excel files, saved as a backup. Previously it didn’t “count it” for the iteration but now it is and it’s not working because I use the current file to append data, so it says that I can’t save the file obviously for the ~$ at the beginning of the file name. I’m thinking to use an if, but I would like to know if you guys have some other ideas. Happy automation!!!

Directory.GetFiles(“MyPath”).Where(Function(fname) Not fname.StartsWith("~$"))


Hello vvaidya,

Could you provide an sample workflow for reference?

Actually what I am doing is looping through the excel files in a folder, then append the data from sheet1 to a new excel workbook.
But after doing this there will have same number of temp files starting with ~$ hidden in the folder.
If I run the RPA again, it will also loop through the temp file which cause error.
Instead of only read the files Not starting with ~$, is it possible to remove the ~$ file after append the data? Coz I will reuse the folder and save other new files in it



I guess the temp file is still a xlsx or xls file, just it is starting with ~$ , and it is hidden in the folder even I choose to display hidden files in window folder setting.
However, when I use directory.getfiles().length, it will also Count the hidden files, so is there any ways to remove those hidden files instead?