Success!!!
[lua]
– Our folder name that we’d like to create
local folderName = “MyFolder”
local fileName = “thefile.png” – We only put png because below we’re donwloading a graphic from the web
local lfs = require “lfs”
– get raw path to app’s Documents directory, Temporary directory, wherever…
local temp_path = system.pathForFile( “”, system.DocumentsDirectory )
– change current working directory
local success = lfs.chdir( temp_path ) – returns true on success
– Create a folder named MyFolder
lfs.mkdir( folderName )
local function networkListener( event )
if ( event.isError ) then
print( “Network error - download failed” )
elseif ( event.phase == “began” ) then
print( “Progress Phase: began” )
elseif ( event.phase == “ended” ) then
print( “displaying response image file” )
myImage = display.newImage( event.response.filename, event.response.baseDirectory, 60, 40 )
myImage.alpha = 0
transition.to( myImage, { alpha = 1.0 } )
end
end
local params = {}
params.progress = true
– Above we created the directory in system.DocumentsDirectory, so we have
– to set that as the base here too.
local base = system.DocumentsDirectory
network.download( “http://developer.anscamobile.com/demo/hello.png”, “GET”, networkListener, params, folderName…"/"…fileName, base )
[/lua]
Thanks Rob and Brent and Alberto for helping us all work through it and figure it out!!
-Mario