This simple function/class does not compile:
public string getDC()
{
string retVal = "";
System.Diagnostics.Process pe = new Process();
for(int i=0 ; i<MAX; i++)
{
try
{
pe.Start("C:\\I386\\ping.exe ", IPaddr); // ***ERROR LINE ***//
}
catch (Exception e) {
Console.WriteLine("Error in ping:" + IPaddr + ":" + e.Message) ;
}
}// FOR //
return retVal;
}
The error messafew on compile is:
Static member 'System.Diagnostics.Process.Start(string, string)' cannot be accessed with an instance reference; qualify it with a type name instead
The type or namespace name 'pe' could not be found (are you missing a using directive or an assembly reference?)
IF I replace the error line with:
Process.Start("C:\\I386\\ping.exe ", IPaddr);
It works amd compiles, BUT I cannto trap the return code Eg: I have an array of URLs some are dully Ip addresses and there is no way I can trap the return value of the ping: invalid IP does not get into the catch Part.
How to get this working ?
public string getDC()
{
string retVal = "";
System.Diagnostics.Process pe = new Process();
for(int i=0 ; i<MAX; i++)
{
try
{
pe.Start("C:\\I386\\ping.exe ", IPaddr); // ***ERROR LINE ***//
}
catch (Exception e) {
Console.WriteLine("Error in ping:" + IPaddr + ":" + e.Message) ;
}
}// FOR //
return retVal;
}
The error messafew on compile is:
Static member 'System.Diagnostics.Process.Start(string, string)' cannot be accessed with an instance reference; qualify it with a type name instead
The type or namespace name 'pe' could not be found (are you missing a using directive or an assembly reference?)
IF I replace the error line with:
Process.Start("C:\\I386\\ping.exe ", IPaddr);
It works amd compiles, BUT I cannto trap the return code Eg: I have an array of URLs some are dully Ip addresses and there is no way I can trap the return value of the ping: invalid IP does not get into the catch Part.
How to get this working ?