Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes JFileChooser and network share Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFileChooser and network share" Watch "JFileChooser and network share" New topic
Author

JFileChooser and network share

Andreas Pax Lück
Greenhorn

Joined: Nov 04, 2009
Posts: 18
Hi friends!

I need to display network shares in a JFileChooser. It's possible to show the network shares of the concerning host via the network button. But I'd also like to display them hardcoded by invokation of:



The JFileChooser doesn't do nothing in this case. If I do specify the explicit share ressource it works:



I don't know the shared folders. So, I want to show the list of all shared folders of the concerning host. Is this impossible?

Best regards


PAX


"Wenn man irgendwann mal von allen akzeptiert wird, dann weiß man, dass man irgendwas falsch gemacht hat."
Excerpt by: Mr. Weidner
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

I've tried with my own machine, and if I create a File around an actual share and call its exists() method, it returns true. If I create a File around the network host only (e.g. new File("\\\\hostname")), exists() returns false. As such, java.io.File is not the means to retrieving these. That also means that JFileChooser can't help you out, since it uses java.io.File in the background.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Andreas Pax Lück
Greenhorn

Joined: Nov 04, 2009
Posts: 18
ok, that's really bad.

thanks for your help.

best regards

PAX
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10173
    
    8

If you are using Windoze, you might find this thread useful
http://www.coderanch.com/t/463406/Swing-AWT-SWT-JFace/java/display-contents-My-Network-places
Some more info here http://www.infocellar.com/win98/networkneighborhood-nethood.htm


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Andreas Pax Lück
Greenhorn

Joined: Nov 04, 2009
Posts: 18
these are interesting information. does the nethood location also have a common caption? i realized that its name isn't "NetHood" on systems with a different language than english.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFileChooser and network share
 
Similar Threads
How will i get all the shared folder names in windows7 from entire network
JFileChooser when used in slow network
Retieving full Network Drive Path from jsp
Select directory dialog
How to copy an html file to another folder