File Lua-Txt文件路径

File Lua-Txt文件路径,file,lua,File,Lua,我需要用Lua在一个.txt文件上写。我什么都知道,但没有先找到我的文件。假设它在桌面上(C:\Users\namegoesher\Desktop\file,txt),如何首先找到它?在写东西之前,file:write(“示例”)试试我喜欢这个 将,更改为 function filewrite(filename, filetext) local file = io.open("C:\\Users\\NameGoesHere\\Desktop\\file.txt", "w" ) file:writ

我需要用Lua在一个.txt文件上写。我什么都知道,但没有先找到我的文件。假设它在桌面上(
C:\Users\namegoesher\Desktop\file,txt
),如何首先找到它?在写东西之前,
file:write(“示例”)
试试我喜欢这个 将更改为

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

在Windows中,您需要对路径使用双反斜杠(\)。

我已经看到了,并尝试使用C:\Users\NameGoesher\Desktop而不是“w”,但不起作用:/