Assume we have a PC in our LAN: 192.168.1.122 and it shares only ONE folder 'Shared' with ONE file 'Test.txt' (i.e. \\192.168.1.122\Shared\Test.txt). Now if I want to browse files and folders in \Shared, I write:
File f = new File("\\192.168.1.122\Shared");
File [] list = f.listFiles(); // Here I've got one item - Test.txt file. OK.
But when I try to browse the top level files & folders...
File f = new File("\\192.168.1.122");
... I get nothing in the list [] array. Please, help me with browsing root folders for the LAN device. Thank you!
Expanding from this answer, as vcetinick suggested, you can use
SmbFile.list()
from jCIFS to list (according to the manual)which is what you've been asking. Using jCIFS this might even work when the application is not run on Windows but instead on an operating system where share access doesn't take the form of
\\host\share\path
.