Delete Files in a Disk using Ignition

Hi!
Is there a way to delete a file in a disk using ignition? In our project, we have an inventory wherein each entry has an associated PDF file. What I did is to use system.file.writefile to save the PDF in a predefined path in my disk, and rename that file so that it has the same name as that of my entry (I have to make sure that the name of the entry and that of the PDF are the same as that is what I used to link the PDF to an entry). My problem is, if a user mistakenly attached a a wrong PDF file to an entry (let’s say Entry1), all I can do is delete Entry1.pdf in my database, but not the actual file in the disk. Is there any way to do this? I may be mistaken but I checked all the scripts for system.file and I can’t see any which I can use to delete my file. Thank you very much for your time.

Jython’s python os module can do what you need:import os os.remove('path/to/my/file.pdf')Also look at the utilities in os.path.

3 Likes

Thank you very much! It solved my problem.