Android Question What is the best way to batch move files?

Inman

Well-Known Member
Licensed User
Longtime User
I need to move a bunch of files from subfolders inside a root folder. I parse the subfolders of root folder using a For Next loop and then a nested For Next loop to parse the contents of each subfolder. Since Android does not have Move function, I copy each file using File.Copy2Async() and then delete the source file using File.Delete(). I also display progress of the process using CustomProgressDialog. Since updating progress with every iteration might slowdown the process, I update progress only every 10 files or so.

Now the problem is some of my users are reporting that this batch move process gets stuck after the first few files. The entire UI hangs and the app goes to a suspended state. My question is, is a nested For Next loop the right way to parse and process a bunch of files? This old thread mentions another method of calling the same CopyFile function from itself via CallSubDelayed. Is that a more efficient implementation?
 
Top