0

I have all my intermediate output files which are irrelevant in the end directed to a common directory. My program uses all the files int he directory until my program finishes execution. How can i delete these files after my program has finished execution. I am using the function

shutil.rmtree("Files")

but it gives me the error:

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'Files\Value.json'

James Z
  • 12,209
  • 10
  • 24
  • 44
  • 4
    I'm guessing you still have an open file handle as you try and clean up. Can you post your code? See [how to create a Minimal, Complete, Verifiable Example](https://stackoverflow.com/help/minimal-reproducible-example). – C.Nivs Jul 17 '19 at 16:10
  • 1
    You have another process that waits until your program is done, and then deletes the unneeded objects. Where does your coding attempt not work? [Minimal, complete, verifiable example](https://stackoverflow.com/help/minimal-reproducible-example) applies here. We cannot effectively help you until you post your MCVE code and accurately specify the problem. We should be able to paste your posted code into a text file and reproduce the problem you specified. StackOverflow is not a design, coding, research, or tutorial resource. – Prune Jul 17 '19 at 16:14
  • This is example how waiting for the program finish [[1]](https://stackoverflow.com/questions/50864930/how-to-delete-files-directories-after-subprocess-is-done-with-them#50864968). – Newton José Jul 17 '19 at 16:49

0 Answers0