B4J Question Rename a Folder?

aidymp

Well-Known Member
Licensed User
Longtime User
Hi i have seen many questions & answers regarding renaming files! but what about folders? can it be done?

I need to rename a folder so I can zip it and it will be be able to extract on android?

the layout is exactly the same but the top level folder has a different name.

PC
MainFolder
Sub1
Sub2
~~~
Sub100

Android
.mainfolder
Sub1
Sub2
~~~
Sub100

I zip the main folder then unzip but the Mainfolder name needs changing!

Any help?
 

aidymp

Well-Known Member
Licensed User
Longtime User
This code works for both files and folders:
B4X:
Dim jo1, jo2 As JavaObject
jo1.InitializeNewInstance("java.io.File", Array("c:\temp\bitmaps"))
jo2.InitializeNewInstance("java.io.File", Array("c:\temp\bitmaps2"))
Log(jo1.RunMethod("renameTo", Array(jo2)))

Thank you very much!
 
Upvote 0
Top