How to check if a file exist and erase it?
Blitz3D Forums/Blitz3D Programming/How to check if a file exist and erase it?
| ||
| Hi all, How to check if a unused file exist and erase it? pseudo code: -------------- if fileExit("c:\temp.txt") erase c:\temp.txt endif How to do this in Blitz3d Code? Thanks in advance. Sammy :) |
| ||
file=OpenFile("C:\temp.txt")
if file>0
type_file=FileType("C:\temp.txt")
;you should check if the file exists, it is a directory...
deletefile("C:\temp.txt")
control=FileType("C:\temp.txt")
if control=0 print "File Successfully deleted.."
end if
byez |
| ||
| Hi degac, Thank you for your reply. I simplify as follows:
If FileType("c:\test.txt") = 1
DeleteFile "c:\test.txt"
if FileType("c:\test.txt")=0 print "File Successfully deleted.."
EndIf
Sammy :) |