0

Is there a way in Java to check whether given directory path is on local drive (path like "C:\data\temp") or on shared network (path like "\\<remote_m/c_ip>\share")? Please note that, in windows environment network path can be mapped as drive. So in this case, "Z:\temp" may be actually on network. And similarly we can share local folder and access it as: \\<local m/c ip>\share, even though it is actually on local drive.

OwlR
  • 363
  • 2
  • 16
  • https://stackoverflow.com/questions/3542018/how-can-i-get-list-of-all-drives-but-also-get-the-corresponding-drive-type-remo – OldProgrammer Jul 21 '17 at 20:32
  • @OldProgrammer above questions is about to getting info about all drive, not about how to check given path is on local drive or on shared network. – OwlR Jul 21 '17 at 20:58

1 Answers1

0

You could run, using java: "cmd fsutil fsinfo drivetype {drive letter}" The output will tell you if it's a network drive or not.

Check Run cmd commands through java to see how to use CMD to run commands.

Roy Wasse
  • 372
  • 1
  • 10
  • fsutil require "driver letter", here I have only directory path which may have no drive letter ( for example, \\some ip\share) – OwlR Jul 21 '17 at 20:55
  • If you have the IP address, you can check if the IP address is the same as the local host. You can't share a mapped drive on the network in Windows directy. If symbolic links are used to map a network drive to a local folder that is shared in the network, then I'm not sure how you would handle that scenario. – Roy Wasse Jul 23 '17 at 11:26