Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试制作一个将数据写入文件的程序,以便另一个程序能够从中读取数据。问题是当我正在读取和写入的文件位于我的两个程序之外的另一个目录中时,我无法找到一种方法来执行此操作。我知道还有其他方法可以做到这一点,但我只是认为知道如何做到这一点会很有用。任何人都可以帮助我吗?
您可以使用完整路径,例如
local f1 = io.open('D:/test/b.txt') -- Windows local f2 = io.open('/test/b.txt') -- Unix
或使用相对路径,例如
local f = io.open('../../test/b.txt')
在此示例中,文件位于test父目录的父目录 ( ..) 的目录中。
test
..