Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Note that there could be multiple UNC paths for a single file. For example, </p> <p><code>D:\Workspace\Task Management System\TBMS\src\com\common\dao\fileName.xls</code> can be accessed as <code>\\ashish\common\dao\filename.xls</code> </p> <p>because </p> <p><code>D:\Workspace\Task Management System\TBMS\src\com\common</code> is shared as <code>common</code> </p> <p>on the machine named <code>ashish</code>. If There was another share</p> <p><code>D:\Workspace\Task Management System\TBMS\src\com\common\dao</code> as <code>dao</code></p> <p>then it could also be accessed as <code>\\ashish\dao\filename.xls</code> </p> <p>I don't know if you know what is the root of the share. If you don't then you will have to start at the leaf folder and traverse up looking for the first one that is shared. </p> <p>Next, <strong>how do you find out if a folder is shared?</strong> I do not offhand know of any library that lets you manage windows shared in Java, but there is probably one out there. Even if there isn't it should be easy to parse the output of <code>net share</code>, which gives output as follows on Windows XP:</p> <pre><code>Share name Resource Remark ------------------------------------------------------------------------------- C$ C:\ Default share ADMIN$ C:\WINDOWS Remote Admin IPC$ Remote IPC tmp c:\tmp </code></pre> <p>You will need to ignore the special shares like <code>C$</code>.</p> <p>Finally, you need to identify the computer name. You can use <code>System.getenv("COMPUTERNAME")</code>.</p> <p>So the pseudocode is:</p> <ol> <li>Start with \\ (<code>\\</code>)</li> <li>Append Computer Name (<code>\\ashish</code>)</li> <li>Append \ (<code>\\ashish\</code>)</li> <li>Append shared name of the nearest parent of the file (<code>\\ashish\common</code>)</li> <li>Append rest of full file name (<code>\\ashish\common\dao\filename.xls</code>)</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload