Silverfrost Forums

Welcome to our forums

Open file and close it deleting its content

27 Aug 2016 9:51 #17913

Please remind how to open some file, erase its content if it exists and close with zero size?

27 Aug 2016 12:39 #17914

This is one way (NOT SECURE!)

open(11,file='xx',status='replace')
rewind(11)
endfile(11)
close(11)

This way of truncating a file is not secure because most of the bytes that were originally on the file may still persist on the medium (disk drive, USB flash, etc.). If you are not worried about secrecy, etc., however, this is a simple solution.

27 Aug 2016 9:35 #17917

hollymolly...Good that I stopped and decided to ask the group. I'd easily lost the rest of the night trying to find this. Many thanks Mecej4

8 Sep 2016 6:48 #17998

To remove the file you can use

close(11,status='DELETE')
Please login to reply.