Hi All
This is a spin off question from another post.
The code below is my attempt answer my own question but is throwing up [an error] while compiling. I suspect it may have something to do with the Java bits [Sub RenameTo] which I have taken from another post.
Many Thanks in advance
Regards Roger
The Error Message:
This is a spin off question from another post.
The code below is my attempt answer my own question but is throwing up [an error] while compiling. I suspect it may have something to do with the Java bits [Sub RenameTo] which I have taken from another post.
Many Thanks in advance
Regards Roger
The Error Message:
B4A Version: 9.50
Java Version: 8
Parsing code. (0.09s)
Building folders structure. (0.04s)
Compiling code. (1.04s)
Compiling layouts code. (0.11s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Generating R file. (0.00s)
Compiling debugger engine code. Error
B4A line: 3058
RenameTo(File.DirRootExternal&\
javac 1.8.0_65
shell\src\horsetrailer\B4A\AntennaBearingTool\main_subs_0.java:4403: error: ';' expected
_renameto(RemoteObject.concat(main.mostCurrent.__c.getField(false,"File").runMethod(true,"getDirRootExternal"),RemoteObject.createImmutable("/ABT/")),main.mostCurrent._oldname,RemoteObject.concat(main.mostCurrent.__c.getField(false,"File").runMethod(true,"getDirRootExternal"),RemoteObject.createImmutable("/ABT/")),main.mostCurrent._newname)} };
B4X:
Sub RenameTo(DirName As String, OldFileName As String, NewDirName As String, NewFileName As String) As Boolean
Dim Source As JavaObject
Source.InitializeNewInstance("java.io.File",Array(DirName,OldFileName))
Dim Dest As JavaObject
Dest.InitializeNewInstance("java.io.File",Array(NewDirName,NewFileName))
Return Source.RunMethod("renameTo",Array As Object(Dest))
End Sub
Sub BtnSiteListPlus_click
VibBip
'Looks for file not named correctly in lowercase and renames it correctly
If File.Exists(File.DirRootExternal&"/ABT/", "impsitelist.csv") = False Then 'Only run if file not found
Table = MF_File.ListFiles(File.DirRootExternal & "/ABT/", "*.*", True, False) 'Make list of all files
If Table.Size > 0 Then 'Only run if there is at least 1 file
For i = 0 To Table.Size -1 'Loops to find file incorrectly Cased
OldName = Table.Get(i)
NewName = OldName.ToLowerCase
If NewName = "impsitelist.csv" Then
RenameTo(File.DirRootExternal&"/ABT/", OldName, File.DirRootExternal&"/ABT/", NewName) As Boolean 'Go to Rename Sub
End If
Next
End If
Table.Clear
End If
End Sub