A Alessandra Pellegri Active Member Licensed User Longtime User Sep 3, 2015 #1 In B4A I use your example code to change a folder name: Code: Copy 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 But in B4I it doen't work, how could I do ? Thank you
In B4A I use your example code to change a folder name: Code: Copy 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 But in B4I it doen't work, how could I do ? Thank you
Erel B4X founder Staff member Licensed User Longtime User Sep 3, 2015 #2 Here: Code: Copy Private Sub Application_Start (Nav As NavigationController) NavControl = Nav Page1.Initialize("Page1") NavControl.ShowPage(Page1) Page1.RootPanel.LoadLayout("1") File.WriteString(File.DirDocuments, "1.txt", "Sdfsdf") Dim no As NativeObject = Me Log(no.RunMethod("renameFile::", Array (File.Combine(File.DirDocuments, "1.txt"), _ File.Combine(File.DirDocuments, "111.txt"))).AsBoolean) Log(File.ListFiles(File.DirDocuments)) End Sub #if objc - (BOOL)renameFile: (NSString*)source :(NSString*)target { return [[NSFileManager defaultManager] moveItemAtPath:source toPath:target error:nil]; } #end if Upvote 0
Here: Code: Copy Private Sub Application_Start (Nav As NavigationController) NavControl = Nav Page1.Initialize("Page1") NavControl.ShowPage(Page1) Page1.RootPanel.LoadLayout("1") File.WriteString(File.DirDocuments, "1.txt", "Sdfsdf") Dim no As NativeObject = Me Log(no.RunMethod("renameFile::", Array (File.Combine(File.DirDocuments, "1.txt"), _ File.Combine(File.DirDocuments, "111.txt"))).AsBoolean) Log(File.ListFiles(File.DirDocuments)) End Sub #if objc - (BOOL)renameFile: (NSString*)source :(NSString*)target { return [[NSFileManager defaultManager] moveItemAtPath:source toPath:target error:nil]; } #end if
A Alessandra Pellegri Active Member Licensed User Longtime User Sep 3, 2015 #3 I see in the example you typed 1.txt and 111.txt but does it work for directories also ? If so, on the footprint of the B4A example I could write: Code: Copy Sub RenameFolder(Parent As String, CurrentFolder As String, NewFolder) Dim args(2) As String args(0) = File.Combine(Parent, CurrentFolder) args(1) = File.Combine(Parent, NewFolder) Dim no As NativeObject = Me no.RunMethod("renameFile::", Array( args(0), args(1))).AsBoolean Return End Sub #if objc - (BOOL)renameFile: (NSString*)source :(NSString*)target { return [[NSFileManager defaultManager] moveItemAtPath:source toPath:target error:nil]; }#end if Is it right ? Last edited: Sep 3, 2015 Upvote 0
I see in the example you typed 1.txt and 111.txt but does it work for directories also ? If so, on the footprint of the B4A example I could write: Code: Copy Sub RenameFolder(Parent As String, CurrentFolder As String, NewFolder) Dim args(2) As String args(0) = File.Combine(Parent, CurrentFolder) args(1) = File.Combine(Parent, NewFolder) Dim no As NativeObject = Me no.RunMethod("renameFile::", Array( args(0), args(1))).AsBoolean Return End Sub #if objc - (BOOL)renameFile: (NSString*)source :(NSString*)target { return [[NSFileManager defaultManager] moveItemAtPath:source toPath:target error:nil]; }#end if Is it right ?
A Alessandra Pellegri Active Member Licensed User Longtime User Sep 3, 2015 #4 It works !! Problem solved ! Thank you I think that it wouldn't a bad idea to create a reference wiki for most used nativeobject Upvote 0
It works !! Problem solved ! Thank you I think that it wouldn't a bad idea to create a reference wiki for most used nativeobject