Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cannot used DriveInfo() on UNC drive
Message
From
02/11/2006 03:36:32
 
 
To
01/11/2006 18:51:08
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01166071
Message ID:
01166520
Views:
14
Here is a new approach:
        ' Get the information on a drive by the use of ManagementScope
        Public Function GetDriveInformationManagementScope() As Boolean
            Dim loConnectionOptions As ConnectionOptions = New ConnectionOptions()
            Dim loManagementObject As ManagementObject
            Dim loManagementObjectCollection As ManagementObjectCollection
            Dim loManagementObjectSearcher As ManagementObjectSearcher
            Dim loManagementScope As ManagementScope
            Dim loObjectQuery As ObjectQuery

            loConnectionOptions.Username = cUsername
            loConnectionOptions.Password = cPassword

            ' Use WMI namespace WMI in which management options will be done
            If cUsername.Length > 0 Then
                loManagementScope = New ManagementScope("\\" + cIP + "\root\cimv2", loConnectionOptions)
            Else
                loManagementScope = New ManagementScope("\\" + cIP + "\root\cimv2")
            End If

            ' The ObjectQuery class represents a management query which returns instances or classes 
            loObjectQuery = New ObjectQuery("select * from Win32_LogicalDisk where DriveType=3")

            ' The ManagementObjectSearcher class allows the extration of an object management collection
            ' in regards to the query specified during the instantiation by the use of the
            ' ObjectQuery parameter or directly by a string
            loManagementObjectSearcher = New ManagementObjectSearcher(loManagementScope, loObjectQuery)

            ' The ManagementObjectCollection represents various object management collections extracted from WMI
            loManagementObjectCollection = loManagementObjectSearcher.Get()

            For Each loManagementObject In loManagementObjectCollection
                cVolumeName = loManagementObject("VolumeName")
                cVolumeSerialNumber = loManagementObject("VolumeSerialNumber")
                nAvailableByte = loManagementObject("Availability")
                nFreeSpace = loManagementObject("Freespace")
            Next

            Return True
        End Function
This one allows me to get the drive information of a UNC path that is local or remote. For remote ones, I can only obtain something workable for as long as this is a Windows server. So, for the UNC path I have on the Tera Station, this cannot work.

For local ones, I don't have to initialize the username and password. For remote ones, if I don't initialize the username and password, I get an access is denied message. When I initialize the username and password, I can get the drive information.

There is one thing that is weird however. For a local one, I have 41.6 GB of free space. However, this method returns 446801879040 for the Freespace value. For the remote one, I have 35.8 GB of free space. One this one, the Freespace value is 385367900160. Could it be that there is some kind of conversion I need to do in order to get the proper value?

As for non Windows server UNC path, I don't know of any approach that would do it. There is surely one because when I am in Windows, from Explorer, I can easily see that there is 988 GB of free space on that one.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform