HighTechTalks DotNet Forums  

WMI using the path in WQL

Dotnet Framework (WMI) microsoft.public.dotnet.framework.wmi


Discuss WMI using the path in WQL in the Dotnet Framework (WMI) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
ddoc
 
Posts: n/a

Default WMI using the path in WQL - 11-21-2007 , 05:54 PM






Hello,

I try to find the size of a directory.
I found a method with system.io c #.
But it does not like me.

So I turned to WMI.

I tried various syntaxes but none works.
This puts me "invalid request".

I searched on the net and on msdn.
The syntax for the path is a doubling of \.

In niveeau of MSDN, I found the need here
Http://msdn2.microsoft.com/en-us/library/aa394130.aspx

Do you have an idea?
Thanks for your help because I admit that I was running out of ideas.

String myReq = "SELECT * FROM Win32_Directory WHERE Path='\certif\'
AND Drive='e:'";
ManagementObjectSearcher disk = new
ManagementObjectSearcher(myReq);
ManagementObjectCollection moc = disk.Get();
foreach(ManagementObject mo in moc){
//this results below is associated to one result
of the query SELECT * FROM //Win32_Directory
//update2
//\certif\
//A200742N8187
//e:

if (mo != null)
{
if(mo["FileName"]!=null)

Console.WriteLine(mo["FileName"].ToString());
if(mo["Path"]!=null)
Console.WriteLine(mo["Path"].ToString());
if (mo["CSName"] != null)

Console.WriteLine(mo["CSName"].ToString());
if (mo["Drive"] != null)
Console.WriteLine(mo["Drive"].ToString());
if (mo["FileSize"] != null)

Console.WriteLine(mo["FileSize"].ToString());
if(mo["Name"]!=null)

Console.WriteLine(mo["Name"].ToString());

}
}

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.