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

Discussion in 'B4J Bugs & Wishlist' started by MarkusR, Oct 22, 2018.

  1. MarkusR

    MarkusR Well-Known Member Licensed User

    i missing a rename in File.
    also delete into windows/linux trashcan.
     
  2. stevel05

    stevel05 Expert Licensed User

    MarkusR likes this.
  3. stevel05

    stevel05 Expert Licensed 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)

    Code:
    'Renames the file denoted by this pathname.
    Public Sub RenameTo(DirName As String, FileName As String, NewDirName As String, NewFileName As StringAs 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
     
    ShaneG30 and Star-Dust like this.
  4. Star-Dust

    Star-Dust Expert Licensed User

    Code:
    Sub RenameFolder(Parent As String, CurrentFolder As String, NewFolder)
       
    Dim p As Phone
       
    Dim args(2As String
       args(
    0) = File.Combine(Parent, CurrentFolder)
       args(
    1) = File.Combine(Parent, NewFolder)
       p.Shell(
    "mv", args, NullNull)
    End Sub
     
    ShaneG30 and Peter Simpson like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice