This program gets a list of the processes running and displays them in a ListBox. When one is clicked it puts info about the process such as start time and filename in text boxes. But some of these don't return anything and the text box remains blank and I can't figure out why.
private void ProcessList_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (Process process in Process.GetProcesses())
{
if (process.ProcessName.ToString() == ProcessList.SelectedItem.ToString())
{
FilenameBox.Text = process.StartInfo.FileName; //Does not return
UsernameBox.Text = process.StartInfo.UserName; //Does not return
DirectoryBox.Text = process.StartInfo.WorkingDirectory; //Does not return
StartTimeBox.Text = process.StartTime.ToString();
RespondingBox.Text = process.Responding.ToString();
CreatesWindowBox.Text = process.StartInfo.CreateNoWindow.ToString();
VirtualMemoryBox.Text = process.VirtualMemorySize64.ToString();
}
}
}
Does anyone know why the top three do not return anything?