Lua programming - os.execute() is not working in Windows

前端 未结 4 1427
刺人心
刺人心 2021-01-25 02:06

I\'m creating a function in pure-Lua to scan the files from a directory and put they on a another file.

The command I tryed was:

os.execute( \"dir /B C:         


        
4条回答
  •  时光取名叫无心
    2021-01-25 02:44

    I just tested your code on my computer and it works correct (with my directories, of course). Maybe you are not getting the expected result because your directory string is broken with an newline char, resulting in:

    dir /B C:\Users\Fernando\workspace\Organizator2\s1 > C:\Users\Fernando\
    workspace\Organizator2\temp.txt
    

    The correct should be:

    dir /B C:\Users\Fernando\workspace\Organizator2\s1 > C:\Users\Fernando\workspace\Organizator2\temp.txt
    

    Please try changing the do end to:

    local source = "C:\\Users\\Fernando\\workspace\\Organizator2\\s1" 
    local directory  = ScanDirectory(source, "C:\\Users\\Fernando\\workspace\\Organizator2\\temp.txt") 
    

提交回复
热议问题