This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

File Deletion and Concurrency in Job Service Queue

Hi, I'm using version 7.1. I'm doing some process orchestration and I have a requirement to send an email with an attached .csv which needs to be generated. I have this part working, I create the csv on the job server drive using a script component then pick up and attach the file. My problem is in the deletion. I'm using the FilComponent - DeleteFile component. When it executes it fails saying the file is still in use. When I create the .csv in the script I'm using a StreamWriter with the 'using' 'end using' directives so the StreamWriter should be disposed of and the file unlocked. I tried explicitly calling .Close() on the StreamWriter on top of the 'using' to no effect. I'm wondering if there is some concurrency going on in the job queue that is causing this to happen? Any hints as to how to get this working like I want?

  • try using Dispose() , as definition says:

    Releases all resources used by the TextWriter object.(Inherited from TextWriter.).

    A workaround would be to create another process step at the end of the process to delete the fila, which shoul also work!
  • Thanks mekindad. Thing is the 'using' directive should dispose of the StreamWriter object and make the file available again. I've now tried explicitly closing and disposing of the StreamWriter on top of using 'Using'. Here's a snip

    Using swFile as New StreamWriter(filename, False)
    swFile.WriteLine("First line of csv")
    swFile.WriteLine("Second line of csv")
    swFile.Close()
    swFile.Dispose()
    End Using

    Also, I am doing this in a separate process step already. There are three process steps. The one with the code above to generate the .csv, a SendRichMail component to send the email (a parameter in this component is used to attach the .csv) and then a third step that deletes the file using a FileComponent - DeleteFile component.

    When it gets to the deletion component, it fails, saying that the file cannot be deleted because it's in use.