Windows Forms - Funções de acesso a Disco
Imports System.IO

Module Discos

Listar os discos do sistema

    Public Function ListarDiscos() As List(Of String)
        Dim a As New List(Of String)

        a.Clear()

        For Each drive As DriveInfo In DriveInfo.GetDrives()
            If drive.IsReady Then
                a.Add("Drive: " + drive.Name + " - " + drive.DriveType + " - " + drive.DriveFormat + " - " + drive.VolumeLabel + " - " + drive.TotalSize.ToString() + " - " + drive.AvailableFreeSpace.ToString())
            Else
                a.Add("Drive: " + drive.Name + " - " + drive.DriveType)
            End If
        Next
        Return a
    End Function

Listar arquivos da pasta

    Public Function ArquivosDiretorio(Diretorio As String) As List(Of String)
        Dim a As New List(Of String)
        Dim NomeArquivo As String

        a.Clear()

        Try
            Dim fileEntries() As String = Directory.GetFiles(Diretorio)
            For Each NomeArquivo In fileEntries
                a.Add(NomeArquivo)
            Next

        Catch ex As Exception
        End Try
        Return a
    End Function

Sub-Pastas da Pasta corrente

    Public Function PastasdaPasta(Pasta As String) As List(Of String)
        Dim subdirectoryEntries() As String
        Dim Pastas As String
        Dim a As New List(Of String)

        Try
            subdirectoryEntries = Directory.GetDirectories(Pasta)
            For Each Pastas In subdirectoryEntries
                a.Add(Pastas)
                'num_pastas = num_pastas + 1
            Next
            Return a
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

Listar arquivos da pasta

    Public Function ArquivosDaPasta(pasta As String) As List(Of String)
        Dim a As New List(Of String)
        Dim NomeArquivo As String

        a.Clear()

        Try
            Dim fileEntries() As String = Directory.GetFiles(pasta)
            For Each NomeArquivo In fileEntries
                a.Add(NomeArquivo)
            Next
            Return a
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

Pegar nome do arquivo

Remove o nome da pasta do nome do arquivo

    Public Function PegaNomeArquivo(arquivo As String)
        'recebe a pasta mais o nome do arquivo e só retorna o nome do arquivo
        'devolve apenas o nome do arquivo retirando a pasta onde ele se encontra do path do arquivo
        Dim a As String = arquivo
        Dim x As Integer = 0

        x = a.IndexOf("\", x)
        While x <> -1
            a = a.Substring(x + 1, a.Length - x - 1)
            x = a.IndexOf("\")
        End While
        Return a
    End Function

Pegar pasta do arquivo

Remove o nome do arquivo do nome completo do arquivo(pasta + nomeArquivo)

    Private Function PegaPasta(arquivo As String) As String
        'devolve apenas o nome da pasta retirando o nome do arquivo do path do arquivo
        Dim a As String = arquivo
        Dim x As Integer = 0, z As Integer = 0
        x = a.IndexOf("\")
        While (x <> -1)
            z = x
            x = a.IndexOf("\", x + 1)
        End While
        a = a.Substring(0, z + 1)
        Return a
    End Function
End Module