1

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!

5
  • 1
    Sure you do not have compiler errors in line number 1? `\` is just one backslash... Commented Sep 12, 2012 at 5:33
  • 2
    Looks like this could be the answer to your question stackoverflow.com/questions/8480622/shares-under-ip Commented Sep 12, 2012 at 5:33
  • what if there are nothing else shared ? Commented Sep 12, 2012 at 5:35
  • Not sure thats entirely possible, i think files and folders would have to sit under a network share of some sort Commented Sep 12, 2012 at 5:36
  • @home, sorry for mistake, it should look like: "//192.168.1.122/Shared"" Commented Sep 13, 2012 at 5:56

1 Answer 1

1

Expanding from this answer, as vcetinick suggested, you can use SmbFile.list() from jCIFS to list (according to the manual)

all browseable shares of a server including printers, IPC services, or disk volumes if this resource is a server URL in the form smb://server/,

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.