2014-11-06 80 views
0

我明白这个读取保存在应用程序文件目录中的文件:访问内部存储特定的文件夹

filePath = system.pathForFile("text.txt", system.DocumentsDirectory) 

我需要从另一个文件夹中读取一个文件,而不是我的应用程序,比如,文件夹存在“内部存储/下载”文件夹的任何移动设备,谁会把上面的代码行代替system.DocumentsDirectory

+0

当时它不可能与Corona SDK Apis。 – Piotr 2014-11-06 11:18:51

回答

-1

下面的代码工作。但是,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 
相关问题