tags:

views:

127

answers:

1

How do I gat the the full .exe path

Let us assume with the following string strt["Command"].ToString(); I get this output

C:\Program Files\Analog Devices\SoundMAX\soundmax.exe /tray

but how to I get

C:\Program Files\Analog Devices\SoundMAX\soundmax.exe

ManagementClass mangnmt = new ManagementClass("Win32_StartupCommand");
ManagementObjectCollection mcol = mangnmt.GetInstances();
foreach (ManagementObject strt in mcol)
{
    string[] lv = new String[4];
    lv[0] = strt["Caption"].ToString();
    lv[1] = strt["Location"].ToString();
    lv[2] = strt["Command"].ToString();
    lv[3] = strt["Description"].ToString();
    listView1.Items.Add(new ListViewItem(lv, 0));
}
A: 
   FileInfo fi = new FileInfo(@"C:\Program Files\Analog Devices\SoundMAX\soundmax.exe /tray");
   Console.WriteLine(fi.DirectoryName);
mbcrump
Thank you for the input but this no working. Im dealing with always various locations
Power-Mosfet