星期五, 八月 10, 2012

Smb File Utility Using Problem

When we using the Java CIFS Client Liberay (JCIFI), we may ignore a very important problem when writing file to remote share folder.

Notes: JCIFS is an Open Source client library that implements the CIFS/SMB networking protocol in 100% Java. CIFS is the standard file sharing protocol on the Microsoft Windows platform (e.g. Map Network Drive ...). This client is used extensively in production on large Intranets. 


Usually, we use below code to new a instance of SmbFile:

   SmbFile sFile = new SmbFile(smbpath)

But when writing a file the destination path, this may caused when the file is wring in progress, the file can also be read, but the read a incomplete file is not correct. We'd better to set the file locked.

   SmbFile sFile = new SmbFile(destinationPath, "", null, SmbFile.FILE_NO_SHARE);

When use copyTo(SmbFile) method, we'd better to use such code to make the file locked also.