Files - how to delete files in the system.DocumentsDirectory in the simulator

Is there a way to quickly delete the files in system.DocumentsDirectory in the simulator?

I’m trying to use LFS to create dirs, but I think my code is accessing files from the root directory. Right now I have to make device builds to test, and I can’t debug or print to terminal to see where I’m going wrong.

Ideally I’m looking for way of destroying files in the documents directory each time I compile, so that I can check my code changes are working. Are the files in a directory I can simply clear out each time I run the code, failing that some code I can run at boot up.

How about a more in depth example, tutorial of the LFS? right now its very sparse.

Thanks for any pointers… [import]uid: 137150 topic_id: 35123 reply_id: 335123[/import]

When you’re running your app in the Corona Simulator, choose “File->Show Project Sandbox”
This will open up a window with the app’s directories. You can then delete any files you want from the Documents directory. The same sandbox directory is used every time you run your app in the Simulator.

I’m on OSX, but I’m assuming the same method should be available on Windows.
[import]uid: 70847 topic_id: 35123 reply_id: 139636[/import]

Thanks!!! at last I can see what is happening using LFS. A big help [import]uid: 137150 topic_id: 35123 reply_id: 139641[/import]

Great :slight_smile: [import]uid: 70847 topic_id: 35123 reply_id: 139642[/import]

When you’re running your app in the Corona Simulator, choose “File->Show Project Sandbox”
This will open up a window with the app’s directories. You can then delete any files you want from the Documents directory. The same sandbox directory is used every time you run your app in the Simulator.

I’m on OSX, but I’m assuming the same method should be available on Windows.
[import]uid: 70847 topic_id: 35123 reply_id: 139636[/import]

Thanks!!! at last I can see what is happening using LFS. A big help [import]uid: 137150 topic_id: 35123 reply_id: 139641[/import]

Great :slight_smile: [import]uid: 70847 topic_id: 35123 reply_id: 139642[/import]

local lfs = require “lfs”;

local doc_dir = system.DocumentsDirectory;

local doc_path = system.pathForFile("", doc_dir);

local resultOK, errorMsg;

for file in lfs.dir(doc_path) do

local theFile = system.pathForFile(file, doc_dir);

if (lfs.attributes(theFile, “mode”) ~= “directory”) then

  resultOK, errorMsg = os.remove(theFile);

  if (resultOK) then

     print(file…" removed");

  else

     print(“Error removing file: “…file…”:”…errorMsg);

  end

  end

  end

local lfs = require “lfs”;

local doc_dir = system.DocumentsDirectory;

local doc_path = system.pathForFile("", doc_dir);

local resultOK, errorMsg;

for file in lfs.dir(doc_path) do

local theFile = system.pathForFile(file, doc_dir);

if (lfs.attributes(theFile, “mode”) ~= “directory”) then

  resultOK, errorMsg = os.remove(theFile);

  if (resultOK) then

     print(file…" removed");

  else

     print(“Error removing file: “…file…”:”…errorMsg);

  end

  end

  end