小编che*_*che的帖子

如何获取Lua中的目录列表

我需要LUA中的目录列表

假设我有一个目录路径为"C:\ Program Files"

我需要该特定路径中所有文件夹的列表以及如何搜索该列表中的任何特定文件夹.

需要路径"C:\ Program Files"中所有文件夹的列表

以下是上述路径中的文件夹名称

  1. test123
  2. test4567
  3. 文件夹123
  4. 文件夹456
  5. 文件夹456 789

    需要在列表中获得上述内容,然后必须仅搜索文件夹456 789中的文件夹456等特定字符串.

试过下面的代码.我在下面遗漏的东西: -

local function Loc_Lines( str )
--
local ret= {}   -- 0 lines

while str do
    local _,_,line,tail= string.find( str, "(.-)\n(.+)" )
    table.insert( ret, line or str )
    str= tail
  Print (str)
end

return ret
end


local function Loc_ShellCommand( cmd )
--
local str= nil

    --
    local f= io.popen( cmd )    -- no command still returns a handle :(
     if f …
Run Code Online (Sandbox Code Playgroud)

lua filenames directory-listing

28
推荐指数
4
解决办法
6万
查看次数

如何在字符串中添加双引号字符?

如何在给定字符串中添加双引号字符?

local str = "foo"
Run Code Online (Sandbox Code Playgroud)

如何获取"foo"字符串包含前导和尾随引号的字符串"

lua

4
推荐指数
2
解决办法
1万
查看次数

通过Lua脚本重新启动系统

我需要通过Lua脚本重启系统.我需要在Reboot发生之前编写一些字符串,并且需要在Reboot完成后在Lua脚本中编写一个字符串.

示例:

print("Before Reboot System")

Reboot the System through Lua script

print("After Reboot System")
Run Code Online (Sandbox Code Playgroud)

我怎么做到这一点?

lua

4
推荐指数
1
解决办法
3559
查看次数

标签 统计

lua ×3

directory-listing ×1

filenames ×1