How to read a Flat file present on a remote machine

  • Hi all,

    i have written a script task which will read a flat file and load it into the DB. If the file is not present in the location , my script task will wait for specified duration and retry.

    The problem is , this will work only if both flat file and the script task is present in the same machine(box).

    But my requirement is , the flat file will be present in a remote location , and my package will run in another. So i have to wait for the flat file in another machine say X , if it is present i have to load it , else i have to wait until the file arrives (sleep for 5 min , and retry again).

    any ideas on how to handle this?

    Thanks,

    Arun

    ------

    Dim strFilename1 As String = CStr(Dts.Variables("strFilename").Value)

    Dim fsMyFile As System.IO.FileStream

    Dim bFinished As Boolean = False

    Dim iCount As Integer = 1

    Dim iTimeout As Integer = 60

    Do

    Try

    fsMyFile = System.IO.File.Open(strFilename1, FileMode.Open, FileAccess.ReadWrite, FileShare.None)

    bFinished = True

    fsMyFile.Close()

    Catch ioex As System.IO.IOException

    iCount += 1

    System.Threading.Thread.Sleep(100000)

    End Try

    Loop Until bFinished Or iCount > iTimeout

    If bFinished Then

    Dts.TaskResult = Dts.Results.Success

    Else

    Dts.TaskResult = Dts.Results.Failure

    End If

    ------

  • Not quite sure, but I do know that I am able to load a flatfile with a normal data transformation from a Mapped Network Drive.

    Just wont work so nicely with a BCP task however

    ~PD

  • Found out how to check for the existense of a file. If i give the filename like : \\172.25.35.181\ftpdata\EmptyFlatFileTest1.txt ,

    i was able to check its existense.

    but i faced a problem here. I was able to check the file existense in one windows machine , but i wasn't able to check in another machine. i got "access denied" error message. actually both machines have identical priviledges (full permission) to those folders , but still i got this error. any ideas why this could happen?

    i also want to know using which Userid our mappings will run? will the mappings run using our windows login-id??

    Thanks,

    Arun

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

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