开发者

How can I have the Physical path by giving the network path

开发者 https://www.devze.com 2023-01-27 15:46 出处:网络
Well now i have an issue which is pointing in the use of \"path\'s\" physical and network. I have a SQL server on a Server machine and i have a desktop machine used as client.

Well now i have an issue which is pointing in the use of "path's" physical and network.

I have a SQL server on a Server machine and i have a desktop machine used as client.

I'm runing from my client machine a stored procedure in order to add a streaming data base.

But also before i run this procedure i run another one which prepare the desired "path", this procedure takes:

myPath="\\Server\SharedFolder\SQL\

in order to run the first procedure i have to turn myPath in each physical name:

myPath="DriveLetter:\Public\WorkFiles\SQL\"

Now my Issue is how i will have the physical path, which is build it on the server and which it's from very difficult (to im开发者_JAVA百科posible) to know it?

Basically i need a function which will return me the physical path, which the implementation it's not knowing to me. My developing environment is vb.net 2010

Is there anyone to assist me on this?


You can use the NetShareEnum Windows API for this, passing the server's name as the first parameter, with level 2 or 502. Then you can do a match based on the returned paths.

Of course, you will need special group membership for this (Administrator, Power User, Print Operator, or Server Operator) kind of call to succeed.


Something like this

    Dim foo As String = "\\DLINK_NAS\Volume_1"
    Dim dirInfo As New IO.DirectoryInfo(foo)

    For Each drv As IO.DriveInfo In My.Computer.FileSystem.Drives
        If drv.IsReady AndAlso dirInfo.Name = drv.VolumeLabel Then
            'match here
        End If
    Next
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号