Willy Denoyette [mailto:[EMAIL PROTECTED]] wrote:

> And of course you can call Delete on the   ManagementObject
> to delete the files like:
>
> queryCollection = query.Get();
>    foreach( ManagementObject dataFile in queryCollection ) {
>             // delete file object in the collection
>             dataFile .Delete();
>   }

Thanx, Willy! I was only writing out the details in my example, but Blain's
original question was indeed about deleting, so it's good to point out that
there's an abstract way to delete the file via the ManagementObject
interface. You can also use the InvokeMethod method to call WMI class
specific methods, which in the case of CIM_DataFile are:

<snip>
ChangeSecurityPermissions
Copy
Rename
Delete
Compress
Uncompress
TakeOwnerShipEx
ChangeSecurityPermissionsEx
CopyEx
DeleteEx
CompressEx
UncompressEx
GetEffectivePermission
</snip>

Documentation of these can be found under the Win32_Directory class[1].

Another thing that might be of interest to people working with WMI is the
"Management Strongly Typed Class Generator"[2] which is akin to typed
datasets, but for WMI classes instead. Essentially it sniffs out the
properties of the WMI class and exposes them as direct typed properties on a
typed class that subclasses ManagementObject. Very nice stuff.

Later,
Drew
.NET MVP

[1] ms-help://MS.VSCC/MS.MSDNVS/wmisdk/r_32os2_448p.htm
[2]
ms-help://MS.VSCC/MS.MSDNVS/cptools/html/cpgrfmanagementstronglytypedclassge
neratormgmtclassgenexe.htm

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to