title: How to get the file size and delete file in Lua?
body: <p>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 <code>743 bytes</code>, then the file will be deleted.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>local getDLFile = function(fileToDL)
              local path = system.pathForFile(fileToDL, system.DocumentsDirectory )
              local myFile = io.open( path, "w+b" ) 
              http.request{ 
                  url = "http://www.testfile.com/"..fileToDL, 
                  sink = ltn12.sink.file(myFile),
              }
  
              -- i don't know what is the syntax
              if myFile.size == 743 bytes then
                   myFile.delete
              end             
  
  end
  </code></pre>
  
  <p>Can anyone can help me about my case?</p>