I'm using the Java CIFS Client Library but facing the problem and problem is copyTo function is not working. I have one folder which contains files. I want to read these files to other network path.
String path1 = "//MACHINE-NAME/SHARE-FOLDER"
NtlmPasswordAuthentication auth = new
NtlmPasswordAuthentication(DOMAIN;USERNAME:PASSWORD)
SmbFile readFolder = new SmbFile("smb://MACHINE-NAME/SHARE-FOLDER/",auth)
This is working fine. Then i have another network path and define like this and ShareFolder2 is have the read/write access to 'everyone' user.
String path2 = "//MACHINE-NAME/SHARE-FOLDER2"
NtlmPasswordAuthentication auth = new
NtlmPasswordAuthentication(DOMAIN;USERNAME:PASSWORD)
SmbFile destinationFolder = new SmbFile("smb://MACHINE-NAME/SHARE-FOLDER2/",auth)
ArrayList<SmbFile> readFiles = readFolder?.listFiles()
for(file in readFiles ){
file.copyTo(destinationFolder)
}
If you wanted to copy a file from one shared location to another shared location. You can this like this
ArrayList<SmbFile> readFiles = readFolder?.listFiles()
for(file in readFiles ){
String name = file.properties.getKey("name")
destinationFolder = new SmbFile(foldersInfo?.destinationFolder+"/"+name,auth)
destinationFolder.createNewFile()
file.copyTo(destinationFolder)
}
The file which you want to copy that file must be in the destination folder. First we will create a file with same name in the destination folder then copy to that folder