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

Discussion in 'Android Questions' started by Inman, Aug 25, 2019.

  1. Inman

    Inman Well-Known Member Licensed 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?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Can you post the code?
     
  3. Inman

    Inman Well-Known Member Licensed User

    The code is deeply embedded into the project, with other classes as well. I will try to post a small project tomorrow with the relevant code only.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice