Android Question file copy

elitevenkat

Active Member
Licensed User
Longtime User
Code: Copy
Sub chooser_Result (Success As Boolean, Dir As String, FileName As String)
if Success then

    Dim Dir1 As String = rp.GetSafeDirDefaultExternal("")

    Dim bg As Bitmap = LoadBitmapResize(Dir, FileName, Activity.Width, Activity.Height ,True)
        
    File.Copy(Dir,FileName,Dir1,  FileName)  ------   this line is throwing the error

i get following error

java.io.FileNotFoundException: /storage/emulated/0/Android/data/newkot.com/files/content:/media/external/images/media/34540 (No such file or directory)

Android version 7 samsung j7 max
b4a 7.3 sdk 23


i have included following in mainfest
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"


android:maxSdkVersion="18" />

need help please.
 
it looks like the file does not exist

what are the results of:
Code: Copy
Log( File.Exists( Dir, FileName))
Log( Dir)
Log( Dir1)
Log( FileName)
are the datas valid?
 
Upvote 0
Thanks Knoppi for the response.

dir ContentDir
dir1 /storage/emulated/0/Android/data/newkot.com/files
filename content://media/external/images/media/34873
filename content://media/external/images/media/34873


Code: Copy
Sub chooser_Result (Success As Boolean, Dir AsString, FileName AsString)if Success then
Dim Dir1 AsString = rp.GetSafeDirDefaultExternal("")
Dim bg AsBitmap = LoadBitmapResize(Dir, FileName, Activity.Width, Activity.Height ,True)
 

File.Copy(Dir,FileName,Dir1, FileName) ------ this line is throwing the error  

changed the above as    File.Copy(Dir,FileName,Dir1, "123") works well.

now the problem is to find out the selected file extension and concotinate to "123" file as extn. Exploring...
 
Upvote 0
Upvote 0
file extension: https://www.b4x.com/android/forum/threads/filebasename-fileextension.76320/#post-484181
your FileName looks like a fullpathFilename if you use it with Dir1 then FileCopy concatinate
Dir1 & FileName = /storage/emulated/0/Android/data/newkot.com/files/content://media/external/images/media/34873 and this is
throwing an error

of course it will throw error. we can use the dir1 path and should give a new file name as target. ( i gave "123"). I further found that the new file can be without extension and the code
Code: Copy
    Dim Dir1 As String = rp.GetSafeDirDefaultExternal("")
     
    Dim bg As Bitmap = LoadBitmapResize(Dir1, "123", Activity.Width, Activity.Height ,True)
works fine.
 
Upvote 0

Similar Threads

Back
Top