hi

i am working in vb.net 2005, i am woring network system (my system is client system) how to get my server drive and dir list for the purpose of database backup any one help me.

thanks

Use System.IO.DriveInfo class

Use System.IO.DriveInfo class

how to use that class?

laks_samy,

Bit lazy.

Dim p() As System.IO.DriveInfo
        p = System.IO.DriveInfo.GetDrives()
        For Each d As System.IO.DriveInfo In p
            If d.IsReady Then
                ....
            End If
        Next

laks_samy,

Bit lazy.

Dim p() As System.IO.DriveInfo
        p = System.IO.DriveInfo.GetDrives()
        For Each d As System.IO.DriveInfo In p
            If d.IsReady Then
                ....
            End If
        Next

its working fine my local system drive. But i need to list my server system drive?

Well that is not gonna be easy (unless there is a built-in function in .net I am not aware of)

here is the closet thing I manage to reach.

Add FolderBrowseDialog

Dim ServerName = "server_name"
Dim AdminUserName = "Administrator"
Dim DomainName = "domain_name"
Dim AdminPassword = "administrator_password"
' Initialize WMI
Dim objSWbemLocator As New WbemScripting.SWbemLocator
'or Dim objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")

' Connect to remote PC
Dim objSWbemServices = objSWbemLocator.ConnectServer(ServerName, "root\cimv2", AdminUserName, AdminPassword, "MS_409", "ntlmdomain:" + DomainName)
' Get Logical HDD from Remote PC
'Dim colHDDs = objSWbemServices.ExecQuery("Select * From Win32_LogicalDisk")
Dim colHDDs = objSWbemServices.ExecQuery("Select * From Win32_LogicalDisk where DriveType=3")
Dim StartFolder = "\\" & ServerName & "\" & Microsoft.VisualBasic.Left(colHDDs(0).name, 1) & "$"
FolderBrowserDialog1.SelectedPath = StartFolder
FolderBrowserDialog1.ShowDialog()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.