Volt

delfile

Deletes a file.

Syntax

delfile(path: string) -> void

Parameters

ParameterTypeDescription
pathstringThe file path to delete

Returns

This function does not return a value.

Description

delfile permanently deletes a file at the specified path.

Example

-- Create a file
writefile("temp.txt", "Temporary data")

-- Verify it exists
print(isfile("temp.txt")) -- true

-- Delete it
delfile("temp.txt")

-- Verify it's gone
print(isfile("temp.txt")) -- false

Safe Delete

local function safeDelete(path)
    if isfile(path) then
        delfile(path)
        return true
    end
    return false
end

if safeDelete("myfile.txt") then
    print("File deleted")
else
    print("File didn't exist")
end

On this page