Android Question When saving downloaded file in "File.DirDefaultExternal" folder, getting an error-"FileNotFound"

Rajesh Gupta

Member
Licensed User
Hello Sir,

When saving downloaded file in "File.DirDefaultExternal" folder, getting an error-"FileNotFoundException:/storage/emulated/0/Android/data..."

My code is
B4X:
Sub dd_Complete(Job As HttpJob)
    If Job.Success Then
        ProgressBar2.Visible=False
        lblProgress.Text="Download completed"
        size=Job.GetInputStream.BytesAvailable
        Log(size)
        File.MakeDir(File.DirDefaultExternal, "Busy")
       
        Dim out As OutputStream = File.OpenOutput(File.DirDefaultExternal & "/Busy" , FileName, False)
        File.Copy2(Job.GetInputStream, out)
        Dim Buffer() As Byte 'declares an empty array
        out.InitializeToBytesArray(size)
        Buffer = out.ToBytesArray
        out.WriteBytes(Buffer,0,Buffer.Length)
        out.Close
           
    Else
        Log("Error: " & Job.ErrorMessage)
    End If

My error is
upload_2017-11-23_14-45-6.png
 
Top