cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with deleting files..

KarlHansson
Level 3

Hi,

I have a process where i download a couple of PDF´s from a legacy system to a folder.
After that, the files are being uploaded to an e-service via Web-API.
When i´m about to delete the files afterwards, i can´t since the files are being used...

I´m using the Delete Files from standard utility in BP.
The program that is "blocking" me from deleting the files is automate.exe so kill process is out of the question.
I do not modify the files or anything....

Thing is that is sometimes work, sometimes not, sometimes after 30 sec, sometimes after 10mins so it´s not consistent either.

I have tried all kinds of things with waits, using delete file each by each, delete all etc. etc. but not success.

Anyone encountered something similar or have any good pointers?

Thanks,
Karl



------------------------------
Karl Hansson
RPA Developer
Digital Workforce Nordic Oy
Europe/Stockholm
------------------------------
9 REPLIES 9

ewilson
Staff
Staff
Hi @KarlHansson,

All this logic is contained within one single process, correct? Is it all on the same page or different pages? My guess is the message about the file "being used" is related to the Web API service grabbing them to upload them. When you try to delete them the .NET garbage collector hasn't run against the specific Web API service object yet, so there's still a file lock held in memory.

Cheers,


------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------

Hi @ewilson,

Thanks for the quick response.
Everything is within a single process but on separate sub-pages.
What would be your suggestion?
Run a codestage / specific action to force the .NET garbage collector to empty state?

Thanks,
Karl



------------------------------
Karl Hansson
RPA Developer
Digital Workforce Nordic Oy
Europe/Stockholm
------------------------------

So if you're using a Web API service to upload the files you're passing a Collection containing those files., correct? How are you loading the Collection?

Cheers,

------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------

Hi Karl

Is the delete files the end of your process? If so then it might be worth making the delete the first action in the process rather than the end. This way you delete previously downloaded files before getting new ones and when you upload them to the web api you dont need to wait for them to finish you can just end the process and they will be delete on next run.

------------------------------
Michael ONeil
Technical Lead developer
Everis Consultancy
Europe/London
------------------------------

@ewilson

Files is printed as PDF and downloaded to a temp folder.
We are using "Get Files" to load the Collection from the Temp folder and the upload the via the Web API.

Update... 15:55

I did some test runs and removed the Upload Sub-page from the equation and without that it works without hassle.
So the root of the problem is def. in the WebAPI / Get Files section..
With that being cleared out, what would be the best prospect here?


/Karl

711.png

​​

------------------------------
Karl Hansson
RPA Developer
Digital Workforce Nordic Oy
Europe/Stockholm
------------------------------

@Michael ONeil

It´s now both in the end and the beginning.

A colleague of mine started the build and i am finishing the last parts.
And yes, the last "Detele" is now redundant since i will check the Success Flag as output from Delete Files.
I will try to remove the last one and put the first one after i made sure global data is "reset".
Thanks for the tip.



------------------------------
Karl Hansson
RPA Developer
Digital Workforce Nordic Oy
Europe/Stockholm
------------------------------

ewilson
Staff
Staff
@KarlHansson,

I think @Michael ONeil's suggestion is the easiest approach to addressing this. If you find that you're still having issues an alternative approach is to move away from using the built-in Web API Services feature and switch to using the REST VBO on the DX. You'll end up having to write more plumbing code, but you'll have more flexibility in controlling how the objects are disposed within it's code stages.

Cheers,
​​

------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------

MarcinDabrowski
Level 3

Hello Karl,

I see that colleagues have replied to you with suggestions, but just to chime in:
- I have a process that generates files and saves them in a temp folder. As a house keeping task I have set up a sub process that deletes files older than 2h. This way if something goes wrong, the most recent files can be manually retrieved from the folder
- if you need to delete the files straight away then - assuming you use the scheduler - you could set a trigger with a time delay of, say, 1-2 min, to run after your main process and delete all files in that particular folder
- or perhaps you could run a nightly house keeping tasks that checks if the designated folder contains files, and if true, deletes them all

Just my 2p!

BW

Marcin



------------------------------
Marcin Dabrowski
Software Automation Development Lead
Moorfields Eye Hospital NHS Trust
------------------------------

@ewilson, @Michael ONeil & @Marcin Dabrowski

Hi again and thank you for you efforts.

I have now solved the problem and the easiest way (i think...) to solve it was..

Use the ItemKey and include it in the PDF filename, When using Get Files, Use the last 4 in the ItemKey to fetch those specific files needed at the moment.
So instead of delete after each upload, stack the files until process is done.
Wait with the delete until last step or after process is finished or as a separate sub-process.
Not done with that yet, testing my solution above but i´m sure it will do the trick.

Thanks once again and have a great evening.

All the best,
Karl​​​



------------------------------
Karl Hansson
RPA Developer
Digital Workforce Nordic Oy
Europe/Stockholm
------------------------------