I want to copy files from DirInternal to external using File.Copy2Async and ExternalStorage.
It works, but is very slow and blocks the app (isn't responding Close App - Wait).
Inserting Sleep(50) doesn't improve anything.
Thanks very much
Franz Brunnlechner
It works, but is very slow and blocks the app (isn't responding Close App - Wait).
Inserting Sleep(50) doesn't improve anything.
File.Copy2Async + ExternalStorage:
Dim Storage As ExternalStorage
Dim LFile As ExternalFile
Dim Lfolder As ExternalFile
Dim In As InputStream
Dim out As OutputStream
Storage.Initialize (Me, "Storage")
Lfolder=Storage.Root
For Each f As String In File.ListFiles(File.DirInternal & "/temp")
Dim n As Long = DateTime.Now
In = File.OpenInput(File.DirInternal & "/temp", f)
LFile=storage.FindFile(Lfolder,f)
Log((DateTime.Now - n)) '4131ms
If LFile.Length > 0 Then Storage.DeleteFile(LFile) 'without deleting sometimes corrupt files are created
LFile=Storage.FindFileOrCreate(Lfolder,f)
Log((DateTime.Now - n)) '7979ms
out=Storage.OpenOutputstream(LFile)
Wait For (File.Copy2Async(In, out)) Complete (Success As Boolean)'5:8101ms
Log((DateTime.Now - n)) '8116
File.Delete(File.DirInternal & "/temp", f)
Log ("f: "&f)
out.close
Next
Thanks very much
Franz Brunnlechner
Last edited: