javasambajcifs

List all files and directories with jcifs


I'm trying to list all files and directories from samba. So I create a SmbFile :

SmbFile smb = new SmbFile("smb:\\\\10.0.4.3\\sharedFiles\\")

I am able to create new files, but I can not list files and directories. I'm getting value 2 from smb.getType(), that means it is TYPE_WORKGROUP, so if I do smb.listFiles() I get all servers registered as members of a NetBIOS. Does anyone know what I have to do to be able to get files and directories?


Solution

  • Well, finally I got it, here is the solution that worked for me:

    SmbFile smb = new SmbFile("smb:\\\\10.0.4.3\\sharedFiles\\", "smb://10.0.4.3/sharedFiles/");
    smb.listFiles(); // OK
    

    And it lists all files, with no directories.