1

I am trying to make a program that will write data to a file for another program to be able to read the data from it. The problem is that I can't figure out a way to do this when the file i am reading and writing from is in another directory than both of my programs. I know there are other ways of doing this, but I just thought that it would be useful to know how to do it. Anyone that can help me?

1 Answers1

3

You can use the full path, e.g

local f1 = io.open('D:/test/b.txt')  -- Windows
local f2 = io.open('/test/b.txt')    -- Unix

or use relative path, e.g

local f = io.open('../../test/b.txt')

In this example, the file is in the test directory of the parent directory (..) of parent directory.

Yu Hao
  • 119,891
  • 44
  • 235
  • 294