How to get last modified date for a file using script task

  • Hi, All

    I need to write a script task to get the last modified date for a file into a variable. I created a script task and a variable (date time). I put the variable into the ReadWriteVariables. And here is my code. When I run, there is a deadlock. Can someone help me?

    Public Sub Main()

    '

    Dim vars As Variables

    Dts.VariableDispenser.LockOneForWrite("User::varHttp", vars)

    Dim d As New IO.FileInfo("c:\gong\test.txt")

    Dim updateTime As DateTime = d.LastWriteTime

    vars(0).Value = updateTime

    vars.Unlock()

    '

    Dts.TaskResult = Dts.Results.Success

    End Sub

    Thanks

  • U can get it using ModifiedDate property

  • dgvsbabu (6/20/2008)


    U can get it using ModifiedDate property

    Looks like this line is causing the problem

    Dts.VariableDispenser.LockOneForWrite("User::varHttp", vars)

    Error: A deadlock was detected while trying to lock variables "User::varHttp" for read/write access. A lock cannot be acquired after 16 attempts. The locks timed out.

    Anyone knows why?

    How should I use ModifiedDate property? Is that same as LastWriteTime?

Viewing 3 posts - 1 through 2 (of 2 total)

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