Need som advice on File.Copy

PFlores81

Active Member
Licensed User
Longtime User
woops, I meant some.

Would it be possible to do
this on app load?:
B4X:
If File.Exists(File.DirRootExternal & "/media/audio/ringtones","limbs2.mp3") Then 
   End If
   Else
   Msgbox("Files needed will be copied!","NO")
   End If

I have looked at multiple approaches for this.
 

Jost aus Soest

Active Member
Licensed User
Longtime User
There are more "End If" than "If", so the answer is: No!

But: Of course in principle it is possible to react depending on the existence of a file.
 
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
There are more "End If" than "If", so the answer is: No!

But: Of course in principle it is possible to react depending on the existence of a file.

Yeah I just kind of threw that together. That is what I want it to do. React according to the existence of the file. In the even the file or files exist, the msg would not popup and it would continue with app load.
 
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
basically what I want to happen is upon app load check if the file or files exist. if they do then continue loading. If not then msgbox files will be copied. execute the copy msgbox done and then continue app load
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
basically what I want to happen is upon app load check if the file or files exist. if they do then continue loading. If not then msgbox files will be copied. execute the copy msgbox done and then continue app load

Perhaps this thing works:

B4X:
If File.Exists(File.DirRootExternal & "/media/audio/ringtones","limbs2.mp3")=false Then
Msgbox("Files needed will be copied!","NO")
'loadFiles. Place copying procedure here
End If
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Below code checks if a file does not exist in SD card, it warns you, then it copies the file from another location assuming it exists. Is this what you are looking for?
B4X:
If File.Exists(File.DirRootExternal & "/media/audio/ringtones","limbs2.mp3")=False Then 
      Msgbox(File.DirRootExternal & "/media/audio/ringtones" & "/limbs2.mp3" & " does not exist.","NO FILE")
      'Below copies the file from the internal to an Sd card folder with the same name.
      File.Copy(File.DirInternal & "/media/audio/ringtones","limbs2.mp3",File.DirRootExternal & "/media/audio/ringtones" ,"limbs2.mp3")
  End If
 
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
I will say, I love this community.. Thank you for replying. I will test both and see which suits my needs.. I appreciate your assistance!
 
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
So I ended up doing it like this.. which works for on the fly copy and add.

B4X:
  If File.Exists(File.DirRootExternal & "/media/audio/ringtones","box.mp3")=False Then 
        'Below copies the file from the internal to an Sd card folder with the same name.
        File.Copy(File.DirAssets,"box.mp3",File.DirRootExternal & "/media/audio/ringtones","ZS_Box.mp3")
      u = rm.AddToMediaStore(File.DirRootExternal & "/media/audio/ringtones", "ZS_Box.mp3", "ZS_Box", True, True, True, False)
  End If
 
Upvote 0
Top