1

I would like to rename a directory that I created on the SD card and thought I could easily do that through the File object (something like File.Rename). However, I don't see something that easy. Do I have to copy all of the directory structure to a new directory with the new name, delete all the files in the old directory, and then delete the old directory to do this? Or is there an easy way that I don't know about?

Andris
  • 13
  • 3

1 Answers1

2

You can use Phone.Shell to run the 'mv' command:

Sub Activity_Create(FirstTime As Boolean)
    RenameFolder(File.DirRootExternal, "test1", "test2")
End Sub

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
Erel
  • 1,802
  • 2
  • 15
  • 58