A Repasky

A Repasky

  • NA
  • 231
  • 183.1k

LINQ not working

Jul 19 2011 5:16 PM
My LINQ code is not working.  I used this many times before, but in this program it is not working.  Here is my code:

    static class AutoExtract
  {
 public static string name = null;
  public static string executable = null;
  public static string path = null;

 
  public static void Main()
  {
  try
  {
  //Get Application Path
  path = Output_Files.GetPath();
  Console.WriteLine(path);
 
  //Get XML Data
  XDocument inputDoc = XDocument.Load(path + @"\AutoExtract.xml");
  Console.WriteLine(inputDoc.ToString());

 
  // Query the data
  var q = from c in inputDoc.Descendants("AutoExtract")
  select new
  {
  name = (string)c.Attribute("Name"),
  executable = (string)c.Attribute("Executable"),
  };

 
  foreach (var item in q)
  {
  name = item.name;
  executable = item.executable;
  Console.WriteLine("xxx" + item.name + "xxx" + item.executable + "xxx");

 
  //Run process on program
  ProcessExtract();
  }

 Here is my XML file:

<AutoExtract>
 <Extract Name="WeeklyExtracts" Executable="C:\WeeklyExtracts\WeeklyExtracts\bin\Debug\WeeklyExtracts.exe">
 </Extract>
</AutoExtract>


Does anyone know why this does not work?  And it worked with other programs!

Thanks ahead of time.

arep

Answers (11)