Android Question error ENOENT no such file or directory, trying to copy downaloaded file from DirInternal

omarruben

Active Member
Licensed User
Longtime User
I am trying to open a downloaded file with a default app...
the file is downloaded to Internaldir SUCCESSFULLY
then when trying to copy to external fails :

java.io.FileNotFoundException: /storage/emulated/0/Android/data/taxnow23.progressivegm/files/Pictures/7f41898546d300b08f36b9e96abbbc37973db20f.jpg: open failed: ENOENT (No such file or directory)



B4X:
dim f as string ="http://xxx.xxx./picture.jpg" ' file is successfully downloaded
  Dim dirx As String = File.DirInternal
    Dim job As HttpJob
    job.Initialize("", Me)
    job.Download(f)
    Wait For (job) JobDone(job As HttpJob)
   
   If job.Success Then
     Dim out As OutputStream = File.OpenOutput(dirx, newname, False)
     File.Copy2(job.GetInputStream, out)
     out.Close '<------ very important
     
     If (File.Exists(dirx,newname)) Then
         Log ("file exist")
        File.Copy(dirx,newname,File.DirDefaultExternal,"Pictures/" & newname) ' <------ ERROR
    End If
     
   Else
     Log("Error: " & job.ErrorMessage)
    End If
    job.Release
 
Last edited:

omarruben

Active Member
Licensed User
Longtime User
thank you so much, it works !!!... but i can't used for other files like PDF's, I end up using the code from this post:

 
Upvote 0
Top