This checks that a file exists and then deletes the file, repeating several times if the delete fails.
Requires: Code Snippet File Exists
Code
-
-- Delete file if it exists -- function DeleteFile(strFileName) if FileExists(strFileName) then local fileHandle, strError = os.remove(strFileName) if fileHandle == nil then local intRepeat = 1 repeat fhSleep(300,100) if FileExists(strFileName) then fileHandle, strError = os.remove(strFileName) end intRepeat = intRepeat + 1 until fileHandle ~= nil or intRepeat > 10 if intRepeat > 10 then error(string.gsub(strError,strFileName:match("(.+\\).+"),"Delete Failed: ")) end end end end