Hi,
I would use the mgmtclassgen generator from VS [see
http://msdn.microsoft.com/library/de...lassgenexe.asp ]
, export a class containing the WBEMDateTime and cut and paste the
conversion code .... That's what I've done.
Best regards,
Manfred Braun
(Private)
Mannheim
Germany
mailto:_m*************@manfbraun.de
(Remove the anti-spam-underscore to mail me!)
"Chris Malone" <pe********@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
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[i] +
"\\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[i] + " - Modify date is : " +
(oReturn["LastModified"].ToString()));
}
catch(System.Exception 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