如果你要频繁写文件到flash,然后频繁删除的话,请不要参考demo里的删除文件的方法

demo里的:--[[函数名:deletefile(filename) 功能:删除指定文件中的所有内容 参数:文件名 返回值:无 --]]local function deletefile(filename)--删除指定文件夹中的所...

demo里的:

--[[函数名:deletefile(filename)
功能:删除指定文件中的所有内容
参数:文件名
返回值:无 --]]
local function deletefile(filename)--删除指定文件夹中的所有内容
local filehandle = io.open(filename,"w")
if filehandle then
filehandle:write()--写入空的内容
print("删除成功")
filehandle:close()
else
print("文件不存在或文件输入格式不正确") --打开失败
end
end

这个方法会让你的可用空间越来越少,要使用 os.remove(filename)

if io.exists(filename) then
os.remove(filename)
end


  • 发表于 2019-03-29 16:42
  • 阅读 ( 1648 )

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
不写代码的码农
高鹏

2 篇文章

作家榜 »

  1. 技术销售Delectate 43 文章
  2. 陈夏 26 文章
  3. 国梁 24 文章
  4. miuser 21 文章
  5. 晨旭 20 文章
  6. 朱天华 19 文章
  7. 金艺 19 文章
  8. 杨奉武 18 文章