« Previous Next »

Thread: How do i get Log Parser to release its file handle so i can delete a .CSV file?

Last post 07-14-2009 3:12 PM by maximusdm. 0 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (1 items)

Sort Posts:

  • 07-14-2009, 3:12 PM

    How do i get Log Parser to release its file handle so i can delete a .CSV file?

    Hi. I am using Log Parser 2.0 COM to parse a IISW3C log file to csv output format from C#.NET. If an error is encountered whilst parsing i catch the error and i want to delete the file. However when i try and delete the csv file i get another error saying that i cannot delete it because

    "The process cannot access the file xxx.yyy because it is being used by another process".

    How do i get Log Parser to release its file handle so i can delete the csv file?

    -----here is the code-----
     public static void GetResultsFromBatch(string query)
     {
      LogQueryClassClass LogParser = new LogQueryClassClass();
      COMIISW3CInputContextClassClass pObjInput = new COMIISW3CInputContextClassClass();
      COMCSVOutputContextClassClass pObjOutput = new COMCSVOutputContextClassClass();

      try
      {
       LogParser.ExecuteBatch(query, pObjInput, pObjOutput);
      }
      catch (Exception e)
      {
      }
      finally
      {
       //LogParser - need to find a way to release the handle or dispose this obj
      }
     }

    Error: [System.IO.IOException] = {"The process cannot access the file 'C:\\test.csv' because it is being used by another process."}

    Someone posted the same question here sometime ago but nobody was able to find a solution for this issue :(

    Thank you

     

    MDM
Page 1 of 1 (1 items)
Microsoft Communities