E EvgenyB4A Active Member Licensed User Longtime User Oct 5, 2016 #1 I need to copy or move the number of text files from one folder to another. The target is USB drive. How to show the progress of copying/moving files and then indicate to remove the flash drive when all the files are copied/moved?
I need to copy or move the number of text files from one folder to another. The target is USB drive. How to show the progress of copying/moving files and then indicate to remove the flash drive when all the files are copied/moved?
Erel B4X founder Staff member Licensed User Longtime User Oct 5, 2016 #2 How large are the files? Upvote 0
E EvgenyB4A Active Member Licensed User Longtime User Oct 5, 2016 #3 Erel said: How large are the files? Click to expand... About 10KB. Upvote 0
E EvgenyB4A Active Member Licensed User Longtime User Oct 5, 2016 #4 EvgenyB4A said: About 10KB. Click to expand... Maybe more than 100 files. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Oct 5, 2016 #5 1. Add all the files names to a global list. 2. Create a sub that copies a file, updates the progress bar and calls itself with CallSubDelayed. Code: Copy Sub CopyFile If AllFiles.Size = 0 Then Complete Else Dim f As String = AllFiles.Get(0) AllFiles.RemoveAt(0) File.Copy(...) ProgressBar.Progress = Max(0, 100 - AllFiles.Size) CallSubDelayed(Me, "CopyFile") End Sub Sub Complete Log("Complete") End Sub Upvote 0
1. Add all the files names to a global list. 2. Create a sub that copies a file, updates the progress bar and calls itself with CallSubDelayed. Code: Copy Sub CopyFile If AllFiles.Size = 0 Then Complete Else Dim f As String = AllFiles.Get(0) AllFiles.RemoveAt(0) File.Copy(...) ProgressBar.Progress = Max(0, 100 - AllFiles.Size) CallSubDelayed(Me, "CopyFile") End Sub Sub Complete Log("Complete") End Sub
E EvgenyB4A Active Member Licensed User Longtime User Oct 5, 2016 #6 Erel said: 1. Add all the files names to a global list. 2. Create a sub that copies a file, updates the progress bar and calls itself with CallSubDelayed. Code: Copy Sub CopyFile If AllFiles.Size = 0 Then Complete Else Dim f As String = AllFiles.Get(0) AllFiles.RemoveAt(0) File.Copy(...) ProgressBar.Progress = Max(0, 100 - AllFiles.Size) CallSubDelayed(Me, "CopyFile") End Sub Sub Complete Log("Complete") End Sub Click to expand... Thank you very much. I will try. Upvote 0
Erel said: 1. Add all the files names to a global list. 2. Create a sub that copies a file, updates the progress bar and calls itself with CallSubDelayed. Code: Copy Sub CopyFile If AllFiles.Size = 0 Then Complete Else Dim f As String = AllFiles.Get(0) AllFiles.RemoveAt(0) File.Copy(...) ProgressBar.Progress = Max(0, 100 - AllFiles.Size) CallSubDelayed(Me, "CopyFile") End Sub Sub Complete Log("Complete") End Sub Click to expand... Thank you very much. I will try.
I Inman Well-Known Member Licensed User Longtime User Aug 25, 2019 #7 Erel said: 1. Add all the files names to a global list. 2. Create a sub that copies a file, updates the progress bar and calls itself with CallSubDelayed. Code: Copy Sub CopyFile If AllFiles.Size = 0 Then Complete Else Dim f As String = AllFiles.Get(0) AllFiles.RemoveAt(0) File.Copy(...) ProgressBar.Progress = Max(0, 100 - AllFiles.Size) CallSubDelayed(Me, "CopyFile") End Sub Sub Complete Log("Complete") End Sub Click to expand... Sorry to wake this old thread @Erel but I am curious why you didn't suggest a For Next loop that copies all the files instead of calling the function from itself. I am performing a batch move of files and some users are complaining that the process gets stuck with the UI not responding, even though I am using File.Copy2Async. Does it have something to do with the fact that I am copying all files in a For Next loop, unlike your above suggestion? Upvote 0
Erel said: 1. Add all the files names to a global list. 2. Create a sub that copies a file, updates the progress bar and calls itself with CallSubDelayed. Code: Copy Sub CopyFile If AllFiles.Size = 0 Then Complete Else Dim f As String = AllFiles.Get(0) AllFiles.RemoveAt(0) File.Copy(...) ProgressBar.Progress = Max(0, 100 - AllFiles.Size) CallSubDelayed(Me, "CopyFile") End Sub Sub Complete Log("Complete") End Sub Click to expand... Sorry to wake this old thread @Erel but I am curious why you didn't suggest a For Next loop that copies all the files instead of calling the function from itself. I am performing a batch move of files and some users are complaining that the process gets stuck with the UI not responding, even though I am using File.Copy2Async. Does it have something to do with the fact that I am copying all files in a For Next loop, unlike your above suggestion?
Erel B4X founder Staff member Licensed User Longtime User Aug 25, 2019 #8 Inman said: Sorry to wake this old thread @Erel but I am curious why you didn't suggest a For Next loop that copies all the files instead of calling the function from itself Click to expand... It is indeed a mistake to wake up this thread. This is an old thread based on a solution that is no longer relevant. Upvote 0
Inman said: Sorry to wake this old thread @Erel but I am curious why you didn't suggest a For Next loop that copies all the files instead of calling the function from itself Click to expand... It is indeed a mistake to wake up this thread. This is an old thread based on a solution that is no longer relevant.