"Drive Letters are Evil" RRS feed

  • Question

  • I've seen this mentioned numerous times now, and the way WHS uses drives it certainly makes sense.

    But, when using the SDK WHSInfo Path property (see code below), unless I have missed something (likely), I have not found a way to get anything but a drive letter.  If developers are supposed to be using net share paths (\\WHSMachineName\Photos\) in their application, is there an easy way to do this?  If not, could it be added to a future SDK update?


    Code Snippet

     WHSInfoClass pInfo = new WHSInfoClass();
     Array shares = pInfo.GetShareInfo();

                foreach (WHSInfoIF.IShareInfo pShare in shares)
                      textBox1.Text += "Name: " + pShare.Name + Environment.NewLine;
                      textBox1.Text += "Path To Share: " + pShare.Path + Environment.NewLine + Environment.NewLine;

    Friday, June 1, 2007 9:46 PM

All replies

  • Reproduced in the CTP. It returns the full local path to the shared data.
    Sunday, June 3, 2007 3:13 PM
  • Here's a quick fix. Overriding the method would probably be cleaner...

    Code Snippet
    foreach (IShareInfo share in shares)
    string[] pieces = share.Path.Split('\\');

    string unc = @"\\" +
    System.Environment.MachineName + @"\";

    for (int i = 2; i < pieces.GetLength(0); i++)
    unc += pieces[i] + @"\";

    /* Do something with unc... */

    Sunday, June 3, 2007 4:29 PM
  • Thanks Rafael.  (I was hoping for the override too :-) )
    Wednesday, June 6, 2007 6:41 PM
  • hey Ed, thanks for the feedback - giving the disk path was the original intent. The thought is you might want to scan for music or videos and do something cool and using SMB would be awkward for some applications in the case that they dont understand the \\ notation  


    some of us were talking today about making it point to the share instead,  do you think this would be better?  there are pro's and con's going either way




    Thursday, June 7, 2007 3:32 AM
  • Rather than eliminate existing functionality/code, it'd be nicer if an additional property was added (i.e. UncPath). As you said, one may want to scan shared repositories, locally.

    Thursday, June 7, 2007 4:25 AM
  • Chris - I agree, definitely leave what is there intact.  But adding an additional property or method to to retrieve the UNC path would also be helpful.

    Thanks for listening.

    Thursday, June 7, 2007 10:33 AM