Android Question How to copy file with space into name?

cenyu

Active Member
Licensed User
Longtime User
I have next code to copy one file between two dirs

B4X:
    Activity.LoadLayout("home")
    File.Copy(File.DirAssets, "/Big Space.otf", File.DirInternal, "/Big Space.otf")
    Log ("OK")

But result always is java.io.FileNotFoundException: \big space.otf

How to copy this file with space into its name?
 

Chris2

Active Member
Licensed User
Longtime User
I think it's the "/" you have in the filenames rather than the space. You just need the filename here.
Try
B4X:
File.Copy(File.DirAssets, "Big Space.otf", File.DirInternal, "Big Space.otf")
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Files in Assets are lowercased.
Rename the file to be lowercase and try again
 
Upvote 0

cenyu

Active Member
Licensed User
Longtime User
Renaming not work...Still the same error.
I thing that space is the promblem...
 
Upvote 0

Chris2

Active Member
Licensed User
Longtime User
Interestingly, I'm testing in B4J, but with a file named "Big Space.otf" added to the files tab,
B4X:
File.Copy(File.DirAssets, "/Big Space.otf"....
and
B4X:
File.Copy(File.DirAssets, "Big Space.otf".....
and
B4X:
File.Copy(File.DirAssets, "\Big Space.otf".....
all work fine for me.

In your error:
java.io.FileNotFoundException: \big space.otf
does the fact you have a backslash '\' rather than a forward slash '/', or that the error filename is all lower case point to something?
When I force a FileNotFoundException, the case of the error text reflects that of the file name exactly.
 
Upvote 0

cenyu

Active Member
Licensed User
Longtime User
This is small project.... The main objective is to copy entire dir with sub dirs from DriAsset to DirInternal.
 

Attachments

  • FileCopy.zip
    88.8 KB · Views: 177
Upvote 0
Top