发帖
充值
 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
0 1

分享源码11- 遍历文件夹下目录

源码分享 7372 0 2024-8-10 10:35:22
本帖最后由 lpopbxjz 于 2024-8-10 11:05 编辑

唉..  最近想写个安卓项目,没用按键 直接用的懒人,结果发现啥啥都没有,论坛上很多都找不到..这次项目用到的一些基础代码就发出来吧,希望懒人越来越好...

留下评论支持,谢谢,看着有评论也心情好哎,以便下次再次分享...

function 遍历文件夹下目录(路径)

        local path = 路径
        for file in lfs.dir(path) do

                if file ~="." and file ~=".."  then
                        --print(file)
                        local path1 = path .."/"..file
                        for file1 in lfs.dir(path1) do
                                if file1 ~="." and file1 ~=".."  then
                                        --print(file1)
                                        local path2 = path .."/"..file.."/"..file1
                                        for file2 in lfs.dir(path2) do
                                                if file2 ~="." and file2 ~=".."  then
                                                        print(path .."/"..file.."/"..file1.."/"..file2)
                                                end
                                        end

                                end
                        end
                end


        end


end

因涉及到了文件路径  临时修改了一下  希望不会报错...

使用道具 举报

您需要登录后才可以回帖 立即登录
高级模式
返回
源码分享