Search code examples
javafilesystemsmkdirsambadirectory

How to create directories using samba client


I have a java code for samba client that puts a file from my unix machine to a windows machine. I need to check if a directory exits, and if not, create the directory and then put the file in that directory. I am able to put the file in an existing directory. It is the creating a new directory part that seems tricky.


Solution

  • if you use JCIFS lib you can create a directory using SmbFile

     SmbFile sFile = new SmbFile(path, authentication);        
     sFile.mkdir();
    

    For more information see the documentation