peacemaker Expert Licensed User Longtime User Jul 21, 2019 #1 HI, All Good snippet - https://www.b4x.com/android/forum/threads/b4x-copyfolder-deletefolder.69820/#content But if lots of folders & subfolders with many files - it's looooong process. How to control it, detecting the finish ? 5 default seconds of the ativity response is not enough.
HI, All Good snippet - https://www.b4x.com/android/forum/threads/b4x-copyfolder-deletefolder.69820/#content But if lots of folders & subfolders with many files - it's looooong process. How to control it, detecting the finish ? 5 default seconds of the ativity response is not enough.
DonManfred Expert Licensed User Longtime User Jul 21, 2019 #2 Add some sleep and wait for and make it all a resumeable sub so you should be able to get the result. Upvote 0
Add some sleep and wait for and make it all a resumeable sub so you should be able to get the result.
Erel B4X founder Staff member Licensed User Longtime User Jul 22, 2019 #3 This code is synchronous. Code: Copy CopyFolder(...) Log("This is the next statement) If it is too slow then you should switch to File.CopyAsync. In that case the sub will be resumable and you will need to call it like this: Code: Copy Wait For (CopyFolder(...)) Complete (Success As Boolean) Upvote 0
This code is synchronous. Code: Copy CopyFolder(...) Log("This is the next statement) If it is too slow then you should switch to File.CopyAsync. In that case the sub will be resumable and you will need to call it like this: Code: Copy Wait For (CopyFolder(...)) Complete (Success As Boolean)
peacemaker Expert Licensed User Longtime User Jul 22, 2019 #4 Erel said: This code is synchronous. Click to expand... If so, the whole recursive loop should finish after all copied, correct ? I found in my app that if to finish activity just after CopyFolder - many files\subforders are not copied yet. If do not finish - all are OK. I guessed that many recursive calls are in the memory and the finish moment is not known well. How to understand ? Upvote 0
Erel said: This code is synchronous. Click to expand... If so, the whole recursive loop should finish after all copied, correct ? I found in my app that if to finish activity just after CopyFolder - many files\subforders are not copied yet. If do not finish - all are OK. I guessed that many recursive calls are in the memory and the finish moment is not known well. How to understand ?
Erel B4X founder Staff member Licensed User Longtime User Jul 22, 2019 #5 The synchronous code should always work or end with an "application not responding error. It will not be interrupted even if the activity is paused. Upvote 0
The synchronous code should always work or end with an "application not responding error. It will not be interrupted even if the activity is paused.
peacemaker Expert Licensed User Longtime User Jul 22, 2019 #6 So, in your recursive code each file copy should finish before next file copying without File.CopyAsync? But ... not finished. Upvote 0
So, in your recursive code each file copy should finish before next file copying without File.CopyAsync? But ... not finished.
Erel B4X founder Staff member Licensed User Longtime User Jul 22, 2019 #7 Yes. File.Copy is a blocking method. Add some log messages and check the size of the copied file. Upvote 0