Hi,
I am trying to rename a file. I know the ntfs name of the string and the ntfs filename, but when I try to rename the file the command fails returns false.
It's obvious that the Java code doesn't like the format of the path and file names. I know you can convert a java type file object to the "canonical" pathname/filename, but how do you do the reverse so that the java code gets what it wants.
I want to use the "normal" ntfs filenames as there's too much smoke and mirrors in Java. You never know where its putting things or why. if you don't jnow where things are you can't be sure you are backing them up.
I know I could copy the file to the filename I want, but that's inefficient, OK for small files but not for large files and/or many at a time.
How can I do what I want?
best regards
Rob
I am trying to rename a file. I know the ntfs name of the string and the ntfs filename, but when I try to rename the file the command fails returns false.
Rename a file:
'======================================================================================================
Sub renameTo(Folder As String, FileName As String, NewFileName As String) As Object
Dim fileJO As JavaObject
fileJO.InitializeNewInstance("java.io.File", Array(File.Combine(Folder, FileName)))
Dim newFileJO As JavaObject
newFileJO.InitializeNewInstance("java.io.File", Array(File.Combine(Folder, NewFileName)))
Return fileJO.RunMethod("renameTo", Array(newFileJO))
End Sub
'======================================================================================================
Sub btnClearRecentList_Click
Dim jmf As MF_File
Dim dataDir = "G:\B4J\fileEntryClass\Files"
Dim dbRecentFilename = "RecentFilesDB.db"
Dim backupFileName = "RecentFilesDB_2020_09_14_13_04_27.db"
result = renameTo(dataDir, dbRecentFilename, backupFileName) '**** Fails ****
End Sub
It's obvious that the Java code doesn't like the format of the path and file names. I know you can convert a java type file object to the "canonical" pathname/filename, but how do you do the reverse so that the java code gets what it wants.
I want to use the "normal" ntfs filenames as there's too much smoke and mirrors in Java. You never know where its putting things or why. if you don't jnow where things are you can't be sure you are backing them up.
I know I could copy the file to the filename I want, but that's inefficient, OK for small files but not for large files and/or many at a time.
How can I do what I want?
best regards
Rob