Getting File Names from Project Directory

Hello,

I am trying to get file names in my project directory. It seems working fine in simulator, but when I load it to Android phone, I get a director error as:
Failed to execute new(params) function on screen2.
The code is as below:

local doc_path = system.pathForFile("/muzik")

fileCount = 1

for file in lfs.dir(doc_path) do
if (string.find(file, “.ogg”)) ~= nil then
soundFNameStrings[fileCount] = file
fileCount = fileCount + 1
end
end

I tried to give second parameter to system.pathForFile(), like system.ResourceDirectory, system.DocumentsDirectory etc.

What may be the problem.

Thanks. [import]uid: 183134 topic_id: 34755 reply_id: 334755[/import]

No idea? [import]uid: 183134 topic_id: 34755 reply_id: 138128[/import]

I don’t think you can start the file with a / since filenames need to be relative to the sandbox the app is running in.

Secondly, on Android, there really isn’t a system.ResourcesDirectory to pull from as it’s just a zip file. See item #3 on this link:

http://www.coronalabs.com/blog/2012/09/26/faq-wednesday-ios-builds-api-docs-and-android/
[import]uid: 199310 topic_id: 34755 reply_id: 138205[/import]

No idea? [import]uid: 183134 topic_id: 34755 reply_id: 138128[/import]

I don’t think you can start the file with a / since filenames need to be relative to the sandbox the app is running in.

Secondly, on Android, there really isn’t a system.ResourcesDirectory to pull from as it’s just a zip file. See item #3 on this link:

http://www.coronalabs.com/blog/2012/09/26/faq-wednesday-ios-builds-api-docs-and-android/
[import]uid: 199310 topic_id: 34755 reply_id: 138205[/import]