Q:

Getting Installed Steam Games From Registry

Can someone help me with this error I'm getting?  Error14 'Using' operand of type 'System. Collections. Generic. List(Of String)' must implement 'System. IDisposable'
 Public Function GetInstalledGames() As Object
    Dim enumerator As IEnumerator(Of String) = Nothing
    Dim list As List(Of String) = Directory. GetFiles(String. Concat(Me. SteamPath, "\steamapps")).ToList()
    Using strs As List(Of String) = New List(Of String)()
        enumerator = list. Distinct().GetEnumerator()
        While enumerator. MoveNext()
            Dim current As String = enumerator. Current
            If (current. Contains("appmanifest_") And current. Contains(".acf")) Then
                strs. Add(Path. GetFileName(current).Replace("appmanifest_", "").Replace(".acf", ""))
            End If
        End While
    End Using
    Return strs
End Function

 Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim enumerator As IEnumerator(Of String) = Nothing
        Me.tbOutput. Text = Environment. GetFolderPath(Environment. SpecialFolder. Desktop)
        Me. SteamPath = Conversions. ToString(Me. GetSteamPath())
        Using installedGames As List(Of String) = DirectCast(Me. GetInstalledGames(), List(Of String))
            enumerator = installedGames. Distinct().GetEnumerator()
            While enumerator. MoveNext()
                Dim current As String = enumerator. Current
                Me.lbGames. Items. Add(current)
            End While
        End Using
    End Sub

A:

Stop writing explicit enumerator loops for no reason
Make your functions return types that make sense instead of Object
Don’t sprinkle Using into code without knowing what it does
Pass data between functions through arguments, not class fields

Private Shared Function GetInstalledGames(steamPath As String) As IEnumerable(Of String)
    Dim result As New List(Of String)

    For Each name In Directory. GetFiles(Path. Combine(steamPath, "steamapps"))
        If name. Contains("appmanifest_") AndAlso name. Contains(".acf") Then
            result. Add(Path. GetFileNameWithoutExtension(name).Replace("appmanifest_", ""))
        End If
    Next

    Return result
End Function

Private Sub Form1_Load(sender As Object, e As EventArgs)
    Me.tbOutput. Text = Environment. GetFolderPath(Environment. SpecialFolder. Desktop)

    Dim steamPath As String = Me. GetSteamPath()

    For Each current In GetInstalledGames(steamPath).Distinct()
        Me.lbGames. Items. Add(current)
    Next
End Sub

