Lua中如何查询文件体积并执行文件删除操作?
- 内容介绍
- 文章标签
- 相关推荐
本文共计207个文字,预计阅读时间需要1分钟。
我使用Lua获取文件大小,遇到问题。正在创建一个函数,如果文件大小为743字节,则删除该文件。以下是代码:
lualocal getDLFile=function(fileToDL) local path=system.pathForFile(fileToDL) if #fileToDL==743 then os.remove(path) endend
我有使用Lua获取文件大小的问题.我正在创建一个函数方法,如果文件的文件大小是743字节,那么该文件将被删除.这是我的代码:
local getDLFile = function(fileToDL) local path = system.pathForFile(fileToDL, system.DocumentsDirectory ) local myFile = io.open( path, "w+b" ) 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
任何人都可以帮助我关于我的情况吗?
要删除文件,请使用os.remove(path).但先关闭文件.
本文共计207个文字,预计阅读时间需要1分钟。
我使用Lua获取文件大小,遇到问题。正在创建一个函数,如果文件大小为743字节,则删除该文件。以下是代码:
lualocal getDLFile=function(fileToDL) local path=system.pathForFile(fileToDL) if #fileToDL==743 then os.remove(path) endend
我有使用Lua获取文件大小的问题.我正在创建一个函数方法,如果文件的文件大小是743字节,那么该文件将被删除.这是我的代码:
local getDLFile = function(fileToDL) local path = system.pathForFile(fileToDL, system.DocumentsDirectory ) local myFile = io.open( path, "w+b" ) 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
任何人都可以帮助我关于我的情况吗?
要删除文件,请使用os.remove(path).但先关闭文件.

