Copying audio file to system.DocumentsDirectory

It says attempt to call field ‘cpFolder’ (a nil value).

Are you using SSK 2 as per the SSK 2 directions?

This is not something you get by default in Corona.

Download it here: https://github.com/roaminggamer/SSK2

Add it to your project as per: https://roaminggamer.github.io/RGDocs/pages/SSK2/#installing-ssk2

Yh, I downloaded ssk2 and put the folder in my project it. It loads it in , but I dont know whats the problem. I just checked my sdk version. Its not the latest. Im gonna update it now and see if the error is fixed.

It’s still not working.

I typoed the sample.

Sorry, but I’m doing this in my ‘brain compiler’ and made a mistake:

 

local files = ssk.files local src = ssk.files.desktop.getDrivePath( "C:\\Users\\Asani\\Music" ) local dst = files.documents.getPath( "music" ) files.util.cpFolder( src, dst )

 
 

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2017/08/musicHelp.zip

clarify not working.

Printing an error?  Not copying folder? what?

It works, thank you so much :slight_smile:

Ah, OK.  I’m getting your responses out of order here.  Got it.

Hi.  You asked me a follow-up question via PM that is closely related to this so I’ll post the answer here.

Also, for future reference I like all my conversations about anything that may help others to be public.


The thrust of your follow-up question, if I understood it, was: “How do I access the Android (internal and/or external) storage?”

While I don’t know specifically how to access, say a plug-in memory card, I can get you started.

The basic answer is, start at root and work your way to the folder you want.

This code will build up the path for the root folder  (ends up just being ‘/’):

local root = ssk.files.desktop.getDrivePath( "/" )

After that, you can build paths to any depth you are allowed access to. 

To help with this, and the common task of finding files in a folder, and or finding a hierarchy, I have some hidden features in SSK2’s  files.* module:

Misc - Utilities ---------------- util.getFilesInFolder( path ) util.findAllFiles( path ) util.keepFileTypes( filesTbl ) util.getLuaFiles( filesTbl ) util.getResourceFiles( filesTbl ) util.flattenNames( filesTbl )

By way of example, this code will return a table containing a list of all files/folders found found in ‘/’

-- ============================================================= require "ssk2.loadSSK" \_G.ssk.init() -- ============================================================= local files = ssk.files local root = ssk.files.desktop.getDrivePath( "/" ) local rootFiles = files.util.getFilesInFolder( root ) if( #rootFiles == 0 ) then rootFiles = { "No Files Found" } end table.dump(rootFiles)

Here is a link to a simple project like the code above that dumps what it found to a pop-up scrollable widget:

https://github.com/roaminggamer/RG_FreeStuff/blob/master/AskEd/2017/08/androidPaths.zip

Oh, and if it wasn’t clear, if you have read and write access to a folder path , then the rest of the files.util.* functions will work on these paths.

Also, the path you’re looking for probably starts with:

  • /sdcard/
  • /storage/
  • /mnt/
  • … or something similar.

Thank you so much again. I was stuck on this for a while.

Thanks roaminggamer

Thanks for your detailed guide. It worked for me