For example my application name is HardwareMonitoring So the process name should be HardwareMonitoring.exe
But what i see is HardwareMonitoring.vshost How can i make that it will show only names without the vshost in the end ?
void PopulateApplications()
{
int rcount = dataGridView1.Rows.Count;
int rcurIndex = 0;
foreach (Process p in Process.GetProcesses())
{
try
{
if (File.Exists(p.MainModule.FileName))
{
if (p.MainModule.FileName.Contains("HardwareMonitoring"))
{
MessageBox.Show("hi");
}
var icon = Icon.ExtractAssociatedIcon(p.MainModule.FileName);
Image ima = icon.ToBitmap();
ima = resizeImage(ima, new Size(25, 25));
ima = (Image)(new Bitmap(ima, new Size(25, 25)));
String status = p.Responding ? "Running" : "Not Responding";
if (rcurIndex < rcount - 1)
{
dataGridView1.Rows[rcurIndex].Cells[0].Value = ima;
dataGridView1.Rows[rcurIndex].Cells[1].Value = p.ProcessName;
dataGridView1.Rows[rcurIndex].Cells[2].Value = status;
}
else
{
dataGridView1.Rows.Add(ima, p.ProcessName, status);
}
rcurIndex++;
}
}
catch ( Exception e)
{
//string t = "error";
}
}
if (rcurIndex < rcount - 1)
{
for (int i = rcurIndex; i < rcount - 1; i++)
{
dataGridView1.Rows.RemoveAt(rcurIndex);
}
}
int f = dataGridView1.Rows.GetRowsHeight(System.Windows.Forms.DataGridViewElementStates.None);
firsttime += 1;
if (firsttime == 1)
{
NumberOfRows = dataGridView1.Rows.Count;
}
if (NumberOfRows != dataGridView1.Rows.Count)
{
int diff = dataGridView1.Rows.Count - NumberOfRows;
NumberOfRows = dataGridView1.Rows.Count;
}
}
It's adding the processes to the rows cells but it's adding vshost and not the regular exe file name. Instead adding HardwareMonitoring.vshost it should add only HardwareMonitoring
How can i fix it ?