我了解这会读取保存在应用程序文档目录中的文件:
filePath = system.pathForFile( "text.txt", system.DocumentsDirectory )
我需要从另一个文件夹而不是我的应用程序中读取文件,例如,任何移动设备的“内部存储/下载”文件夹下都存在该文件夹,请问有人可以将上面的代码行而不是system.DocumentsDirectory
以下代码有效。但是,sdcard实际上意味着应用程序内部的存储。即使第四行直接引用第一行,中间的两行也是代码正常工作所必需的。
filePath = "/sdcard/coordinates.txt"
local file = io.open( filePath, "r" )
local contents = file:read( "*a" )
for line in io.lines(filePath) do
ii=ii+1
points[ii] = line
b1 = points[ii]
c2 = 1
for i in string.gmatch(b1, "%S+") do
b={}
b[c2]=i
if c2 ==1 then bore[ii] = b[c2] end
if c2 ==2 then x[ii] = b[c2] end
if c2 ==3 then y[ii] = b[c2] end
c2=c2+1
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句