解决方法
从
documentation:
io.open (filename [,mode])
This function opens a file,in the
mode
specified in the string mode. It returns a new file handle,or,in case of errors,nil plus an error message.
- local f,err = io.open("filename.txt","w")
- if f then
- -- do something with f
- else
- print("Error opening file: " .. err)
- end
例如,如果进程没有打开文件的权限,则会打印出以下消息:
Error opening file: filename.txt: Permission denied