user2276872
user2276872

Reputation:

Lua - Txt file path

I need to write on a .txt file using Lua. I know everything but not locate my file first. Let's say it is on Desktop (C:\Users\NameGoesHere\Desktop\file,txt), how do I locate it first? Before writing something to it, file:write("Example").

Upvotes: 1

Views: 8295

Answers (1)

NTK88
NTK88

Reputation: 593

try I like this one Change , to .

function filewrite(filename, filetext)
local file = io.open("C:\\Users\\NameGoesHere\\Desktop\\file.txt", "w" )
file:write(filetext)
file:close()
end

In Windows, you need to use double backslashes(\) for paths.

Upvotes: 2

Related Questions