### Move File

To move a file, API methods from the java.io.File class can be used via JavaObject (requires the JavaObject library).
The Java IO class is decribed here:
http://docs.oracle.com/javase/8/docs/api/java/io/File.html
Move File
'Move file
'Returns True if OK, else False
`Sub FileMove(SourceFolder As String, SourceFile As String, TargetFolder As String, TargetFile As String) As Boolean
Dim source, target As JavaObject
source.InitializeNewInstance("java.io.File", Array(SourceFolder, SourceFile))
target.InitializeNewInstance("java.io.File", Array(TargetFolder, TargetFile))
Return source.RunMethod("renameTo", Array(target))
End Sub`
Rename File
The same principle van be used, to rename a file
`Sub RenameFile(source As String, target As String)
Dim joFileSource As JavaObject
Dim joFileTarget As JavaObject
' Create the file instances for the files (the constructor)
joFileSource.InitializeNewInstance("java.io.File", Array As Object(source))
joFileTarget.InitializeNewInstance("java.io.File", Array As Object(target))
' Rename file to
joFileSource.RunMethod("renameTo", Array As Object(joFileTarget))
End Sub`

Changed: , Category: Files, File: T6C193M1385.htm, ID: 1385