Sample code for 30+ languages & platforms
Lua

Remove Directory

See more FTP Examples

Delete a remote FTP directory.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.

local ftp = chilkat.Ftp2.new()

ftp.hostname = "ftp.example.com"
ftp.username = "login"
ftp.password = "password"

-- Connect and login to the FTP server.
local success = ftp:connect()
if not success then
    print(ftp.last_error_text)
    return
end

-- Delete a directory on the FTP server.  The directory
-- must not contain any files, otherwise an error status
-- will be returned.  Most FTP servers do not allow
-- directories containing files to be deleted.
success = ftp:remove_remote_dir("newDirName")
if not success then
    print(ftp.last_error_text)
    return
end

success = ftp:disconnect()