SSIS File System Task Error: The process cannot access the file because it is being used by another process

  • Hello,

    i'm using a foreach loop to loop throught the files of a directory, the files name is saved in a variable "filename". within the loop, i use a file system task to move the files to another directory. i use the same variable "filename" as source of the file system task.

    Now when i execute the whole foreach loop i get this error :

    File System Task Error: The process cannot access the file because it is being used by another process

    Help please 🙁 !!!

  • This was removed by the editor as SPAM

  • Yeah i can tell that it's used by another process thank u, but when i checked i found that it's only used by one process which is DtsDebugHost.exe ( and it is running twice for the same package ).

    Actually i am using a loop within another to loop through the sheets of many excel files. and whenever it navigates through a file i wana move it to another directory. Now when i disable the inner loop (on the sheets) leaving only the loop on files running, it works fine . but when i enable it, the file system task ( used to moving the files ) fails, and i just can't figure out what's wrong!

    PS: when i run the same package in another laptop it works

  • Chances are the issue is due to your package processing files faster than Windows can release the file after processing. I've had that problem many times.

    You could try adding a script task in your ForEach to add a delay to give Windows time to release the file. I'd start with a 30 second delay just to see if this fixes the problem. If it does, try changing the delay to just a few seconds.

    For more information about creating a delay with a script task, see: http://microsoft-ssis.blogspot.com/2011/04/pause-in-ssis.html



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Thank you for ur answer Alvin, i tried the delay option before and it didn't work, still getting the same error...

    i thought maybe it's something related to the package parameters : i tried setting Run64Bitruntime to false ( it didn't help)

    i checked the transaction options : supported, i set delay validation to true for the file system task ...i'm still getting the error

    I'm beggening to think there's something wrong with the ssis 2008 r2 (32) version i have, since the package works fine on an other laptop with ssis 2008 r2 (64).

  • mrani.soukaina (9/9/2015)


    Thank you for ur answer Alvin, i tried the delay option before and it didn't work, still getting the same error...

    i thought maybe it's something related to the package parameters : i tried setting Run64Bitruntime to false ( it didn't help)

    i checked the transaction options : supported, i set delay validation to true for the file system task ...i'm still getting the error

    I'm beggening to think there's something wrong with the ssis 2008 r2 (32) version i have, since the package works fine on an other laptop with ssis 2008 r2 (64).

    The problem could be an issue with Windows or some other process, like anti-virus software.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Have you set OverwriteDestinaton as TRUE.

  • Hi

    I met similar problem, a few years ago I was involved in central repository project.

    It had to move files prepared by users (local servers in branches) to the central server and index it in repository db.

    I created Script Task to check that the file qualify to move (name, length, PDF format). Problems appeared during the first run (returned

    the same error as yours). I did a small change, replaced move operation with copy and added another step which deletes all copied files at the end.

    Best regards

    Mike

  • Hi,

    Thank you all for your help.

    Yes i did try everything you have suggested before but it didn't fix my problem.

    Finally, i added a script task executing the following script to close and dispose any EXCEL.EXE running while i'm executing my package :

    Public Sub Main()

    Dim procList() As Process = Process.GetProcesses()

    Dim k As Integer

    For k = 0 To procList.GetUpperBound(0) Step k + 1

    If procList(k).ProcessName = "EXCEL" Then

    procList(k).Close()

    procList(k).Dispose()

    End If

    Next

    GC.Collect()

    GC.WaitForPendingFinalizers()

    Dts.TaskResult = ScriptResults.Success

    End Sub

    and it works fine now 🙂

  • Its not so obvious , i had the same problem. Please remove crictic developers but not soloutions. Very annoying,

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply