I'm trying to convert into friendly format the "LastModifi ed" property
of an object returned via WMI from remote servers. Every attempt to
manipulate that using DateTime has bombed with "specified cast not
valid" errors, etc. Here is the code:
for(i=0;i<SCORE Array.GetUpperB ound(0);i++)
{
ConnectionOptio ns oConn = new ConnectionOptio ns();
oConn.Username =
oConn.Password =
System.Manageme nt.ManagementSc ope oMs = new
System.Manageme nt.ManagementSc ope("\\\\" + SCOREArray[i] +
"\\root\\cimv2" , oConn);
System.Manageme nt.ObjectQuery oQuery = new
System.Manageme nt.ObjectQuery( "select * FROM CIM_Datafile WHERE Name =
'c:\\\\winnt\\\ \memory.dmp'");
ManagementObjec tSearcher oSearcher = new
ManagementObjec tSearcher(oMs,o Query);
ManagementObjec tCollection oReturnCollecti on = oSearcher.Get() ;
foreach( ManagementObjec t oReturn in oReturnCollecti on )
{
try
{
ListBox1.Items. Add(SCOREArray[i] + " - Modify date is : " +
(oReturn["LastModifi ed"].ToString()));
}
catch(System.Ex ception gen_ex)
{ ListBox1.Items. Add(SCOREArray[i] + gen_ex.Message) ;
}
An example of the output of this property is
"20050105160751 .664062-360". I'm having a terrible time converting that
into a user-friendly date.
Any assistance appreciated.
chris
Comment