1

I'm trying to find a way to access the UNC path of a mapped network drive in my Java application.

Basically I'm saving the full path of a file that the user browses for and chooses. However, I don't want my saved path to include "J:\" and similar letters in the beginning of the path but instead the full mapped network path. How can I access that?

I have been using FileDialog to browse and choose the file but I can change that if I need to.

Thank you

sinsi
  • 51
  • 1
  • 6
  • Hello, welcome to StackOverflow, please post your code so we could better understand your issue. – Marek Jun 08 '14 at 05:45
  • @Marek actually I think the question is complete without any code. Given a path which uses a mapped drive letter how do you get the UNC path the drive letter is mapped to. There's not really any code required to explain that further. – Nerdtron Jun 08 '14 at 13:03
  • @sinsi see [here](http://stackoverflow.com/questions/5722146/how-to-retrieve-the-unc-path-instead-of-mapped-drive-path-from-jfilechooser). One of the answers there suggests using getDisplayName() which might work for you. Note that if you just search for UNC path here you'll find multiple questions on this. – Nerdtron Jun 08 '14 at 13:05
  • Hello @nerdtron I read every one of those answers and none of them give a solution to this, at least not for Java. The getDisplayName() included as it only returns the listed display names of the mapped network drives (as shown in "My Computer") which may be edited by the user at any time and not the actual UNC path itself – sinsi Jun 08 '14 at 14:15
  • Hello @moonlightcheese in the following link: http://stackoverflow.com/questions/5722146/how-to-retrieve-the-unc-path-instead-of-mapped-drive-path-from-jfilechooser you mentioned in a comment that you found a way to get the UNC path using 'ipconfig /all'. Please can you elaborate on how you did that? PS: sorry for not commenting there but I do not have enough "reputation points" or whatever it is to comment there... – sinsi Jun 08 '14 at 14:29
  • @sinsi one of the suggestions there was to use the "net" command and parse the output. That one should definitely work as that command will show you the UNC path for each mapped drive letter. – Nerdtron Jun 08 '14 at 21:03
  • @sinsi I think you must not have tried the one which uses the "net use" command. That should do it for you. – Nerdtron Jun 11 '14 at 17:45
  • @Nerdtron THANK YOU! I guess I must have missed it cuz the answer is part of the question which is weird! thanx again, works perfectly:) – sinsi Jun 14 '14 at 07:52

1 Answers1

3

Answer taken from the following link:

How to retrieve the UNC path instead of mapped drive path from JFileChooser

The answer was edited into the question.

Community
  • 1
  • 1
sinsi
  • 51
  • 1
  • 6