Tech Off Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

invalid WQL when using \\

Back to Forum: Tech Off
  • User profile image
    shax

    Hi, i'm having a problem with a wql query, every time i use \\ to specify a pathname i get invalid query error.

    i can make the query work if i separate the "microsoft.net" and the "framework" but that's not what i want. Can anyone tell me why is this an invalid query?

    oq = new ObjectQuery("Select * from CIM_Datafile Where Extension = 'dll' and FileName = 'mscorlib' and path like '%microsoft.net\\framework%'");

    query = new ManagementObjectSearcher(ms, oq);
    queryCollection = query.Get();

    foreach (ManagementObject mo in queryCollection)
    {
         Console.WriteLine(mo["Name"].ToString());
         Console.WriteLine(mo["Version"].ToString());
    }

  • User profile image
    shax

    Fixed, tkns to Alanfo from gotdotnet.

    --

    Try placing an @ before the query string, which worked on my machine:

    oq = new ObjectQuery(@"Select * from CIM_Datafile Where Extension = 'dll' and FileName = 'mscorlib' and path like '%microsoft.net\\framework%'");

    -Alan

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.