From the documentation :
io.open (filename [, mode])
This function opens the file in the modespecified string mode. It returns a new file descriptor or, in case of errors, nil plus an error message.
A usage example using the second value returned by the function is as follows:
local f, err = io.open("filename.txt", "w")
if f then
-- do something with f
else
print("Error opening file: " .. err)
end
If the process does not have permission to open the file, for example, the following message will be printed:
Error opening file: filename.txt: Permission denied
source
share