2014-11-06 68 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 
相關問題