How to get the file size and delete file in Lua?

I have problem in getting the size of the file using Lua. I am creating a function method that if the file size of the file is 743 bytes, then the file will be deleted.

Here is my code :

local getDLFile = function(fileToDL)
            local path = system.pathForFile(fileToDL, system.DocumentsDirectory )
            local myFile = path, "w+b" ) 
                url = ""..fileToDL, 
                sink = ltn12.sink.file(myFile),

            -- i don't know what is the syntax
            if myFile.size == 743 bytes then


Can anyone can help me about my case?


The size is given by myFile:seek("end").

To delete the file, use os.remove(path). But close the file first.

Recently Lua File System support was added to Corona! You can get file size using

local lfs = require "lfs"
local size = lfs.attributes (path, "size")

You can have a read here

To delete the file use


Need Your Help

How to change the position of a progress dialog?

android position alignment progressdialog

I'm developing an android app and need to know how to change the positioning of a progress dialog. I need it to be positioned at the bottom of the screen instead of at the center like it is by defa...

Merge pull request to a different branch than default, in Github

git github pull-request

A pull request comes into my repo hosted on Github. By default it is merged into the master branch.