Wish File.Rename and File.Delete(into trashcan)

MarkusR

Well-Known Member
Licensed User
Longtime User
i missing a rename in File.
also delete into windows/linux trashcan.
 

stevel05

Expert
Licensed User
Longtime User
OK, the RenameTo in the Library looks like it only moves in the same directory. This one will work anywhere (That you have the correct access rights to)

B4X:
'Renames the file denoted by this pathname.
Public Sub RenameTo(DirName As String, FileName As String, NewDirName As String, NewFileName As String) As Boolean
    Dim Source As JavaObject
    Source.InitializeNewInstance("java.io.File",Array(DirName,FileName))
    Dim Dest As JavaObject
    Dest.InitializeNewInstance("java.io.File",Array(NewDirName,NewFileName))
    Return Source.RunMethod("renameTo",Array As Object(Dest))
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
B4X:
Sub RenameFolder(Parent As String, CurrentFolder As String, NewFolder)
   Dim p As Phone
   Dim args(2) As String
   args(0) = File.Combine(Parent, CurrentFolder)
   args(1) = File.Combine(Parent, NewFolder)
   p.Shell("mv", args, Null, Null)
End Sub
 
Top