Hi all. I've been working on a small program, and I need to get the Process ID by the name. This is what I have:

Dim Processes() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessesByName(ProcessName)
Dim Process As System.Diagnostics.Process = Processes(0)
Dim id = Process.Id

But I always get this error: Index was outside the bounds of the array. The process I'm using at the moment is running.

Dim ProcessName As String = "explorer" 'without the extension
        Dim Processes() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessesByName(ProcessName)
        If Processes.Count = 0 Then
            Debug.WriteLine("Process not found.")
            Return
        End If

        Dim id = Processes(0).Id
        Debug.WriteLine(id)