C
Chris Malone
I'm trying to convert into friendly format the "LastModified" 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<SCOREArray.GetUpperBound(0);i++)
{
ConnectionOptions oConn = new ConnectionOptions();
oConn.Username =
oConn.Password =
System.Management.ManagementScope oMs = new
System.Management.ManagementScope("\\\\" + SCOREArray +
"\\root\\cimv2", oConn);
System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("select * FROM CIM_Datafile WHERE Name =
'c:\\\\winnt\\\\memory.dmp'");
ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(oMs,oQuery);
ManagementObjectCollection oReturnCollection = oSearcher.Get();
foreach( ManagementObject oReturn in oReturnCollection )
{
try
{
ListBox1.Items.Add(SCOREArray + " - Modify date is : " +
(oReturn["LastModified"].ToString()));
}
catch(System.Exception gen_ex)
{ ListBox1.Items.Add(SCOREArray + 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
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<SCOREArray.GetUpperBound(0);i++)
{
ConnectionOptions oConn = new ConnectionOptions();
oConn.Username =
oConn.Password =
System.Management.ManagementScope oMs = new
System.Management.ManagementScope("\\\\" + SCOREArray +
"\\root\\cimv2", oConn);
System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("select * FROM CIM_Datafile WHERE Name =
'c:\\\\winnt\\\\memory.dmp'");
ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(oMs,oQuery);
ManagementObjectCollection oReturnCollection = oSearcher.Get();
foreach( ManagementObject oReturn in oReturnCollection )
{
try
{
ListBox1.Items.Add(SCOREArray + " - Modify date is : " +
(oReturn["LastModified"].ToString()));
}
catch(System.Exception gen_ex)
{ ListBox1.Items.Add(SCOREArray + 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