Hi All,

I hope someone out there can help with this.

I'm writing an app where a user selects a folder on the network for a job to deposit output into.

The person setting up the job will not necessarily be the same person who runs the job and that the job will not be ran on the same machine so I need to keep the path in UNC format.

I can get the user to "see" the network when the FolderBrowserDialog runs by pointing the route folder at the desktop folder.

The issue is that if the network share is local even though the user has selected the folder through the network folders it returns the local path!! Which of course means that when the job is run on the other machine it can not find the folder specified.

E.g. The user on machine1 selects the network share \\machine1\jobs\myjob but the dialog returns C:\work\2010Jobs\Client\jobs\myjob. machine2 then runs the job and looks for C:\work\2010Jobs\Client\jobs\myjob and can not find it then throws an error.

As you can see from the above example I can't just replace c:\ with the local machine name as the share may not be in the root of the drive.

I did think about parsing the text and changing it to \\machine1\c$\work\2010Jobs\Client\jobs\myjob but this would mean I'd have to allow all the users to have admin access to our servers which is a non starter.

Does anyone know if there is a way to switch off this behaviour in the dialog?

dim myDialog as new FolderBrowserDialog

         With myDialog
            .Description = "Browse to Job destination"
            .ShowNewFolderButton = True
            .RootFolder = Environment.SpecialFolder.Desktop
            .SelectedPath = "My Network Places\Entire Network\Microsoft Windows Network\"
        End With
        If myDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
           sMyPath =  myDialog.SelectedPath
        End If

That's great it looks like what I'm looking for, I had been trying launching the DOS command as a process, passing in net share as an arguement then trying to read back the output so I could compare to the returned path and hence change back to the UNC - yuck!

I spoke too soon, I could not stop it giving me back the local path....

So.....

I found some code on line that allows me to parse through the network structure returning objects using the mpr.dll so i'll play around with that so I get back all the network shares and their local paths on the machine and then compare to the path from the dialog.

This article has been dead for over six months. Start a new discussion instead.