函数:file.move 移动文件

函数名称:移动文件

函数功能:移动文件到新的目录下

函数方法

flag = file.move(path,tpath)

参数 类型 必填 说明
path string 待移动文件的路径,
相对路径(仅支持 v1.0.6 及其以上版本)如 "ceshi.png" 表示当前流程文件夹下的 ceshi.png 文件
tpath string 要移动到的文件路径,注意先判断是否有重名文件或文件夹,
相对路径(仅支持 v1.0.6 及其以上版本)
返回值 类型 说明
flag boolean true - 移动成功,false - 移动失败

函数用例

--相对路径,仅支持 v1.0.6 及其以上版本
--相对路径为当前流程文件夹:/sdcard/LuaBox/Projects/流程名称/
--待移动文件的路径,表示当前流程文件夹下的 222.log 文件
path = "222.log"
--要移动到的文件夹,表示当前流程文件夹下的测试文件夹
tpath = "测试/"
--判断文件是否存在
flag1 = file.isExist(path)
flag2 = file.isExist(tpath)
if  flag1 and flag2 then
      flag3=file.move(path,tpath.."error.log")
    if  flag3 then
        dialog("移动成功",5000)
    else
        dialog("移动失败",5000)
    end
else
    dialog("文件(夹)不存在",5000)
end
--待移动文件的路径
path = "111.lua"
--要移动到的文件夹
tpath = "测试/"
--判断文件是否存在
flag1 = file.isExist(path)
flag2 = file.isExist(tpath)
if  flag1 and flag2 then
      flag3=file.move(path,tpath.."222.lua")
    if  flag3 then
        dialog("移动成功",5000)
    else
        dialog("移动失败",5000)
    end
else
    dialog("文件(夹)不存在",5000)
end

注意事项

  • 待移动和要移动到的文件路径必须带文件名,文件名和扩展名可修改。

  • 目前积木编程函数和触动精灵函数不通用,请仔细查看本手册,此手册中函数仅支持积木编程,不支持触动精灵,同理请勿将触动精灵函数在积木编程运行。

Copyright 北京帮你玩科技有限公司 2022 all right reserved,powered by Gitbook该文章修订时间: 2023-08-09 17:19:31

results matching ""

    No results matching ""