Scenario:
We need to download or remove the file from FTP Server. But let's say the file is not present. If we try to download or delete the file we will get an error as file is not available. How we can avoid this error in SSIS Package.What we will learn this in video
- How to run couple of test with FTP Task to Fail if File not exists in SSIS Package
- Create Variables to hole remote path, File Name , Local Folder paths in SSIS Package
- How to create FTP Connection Manager and use in Script Task
- How to create Flag variable in SSIS Package and update the value in Script task depending upon the availability of file on FTP Server
- How to use Precedence Constraint in SSIS Package to handle the flow of Tasks
Public Sub Main() Dim StrFolderArrary As String() Dim StrFileArray As String() Dim fileName As String Dim RemoteDirectory As String RemoteDirectory = Dts.Variables("User::RemoteFolder").Value.ToString() Dim cm As ConnectionManager = Dts.Connections("FTPConnection") 'FTP connection manager name Dim ftp As FtpClientConnection = New FtpClientConnection(cm.AcquireConnection(Nothing)) ftp.Connect() 'Connecting to FTP Server ftp.SetWorkingDirectory(RemoteDirectory) 'Provide the Directory on which you are working on FTP Server ftp.GetListing(StrFolderArrary, StrFileArray) 'Get all the files and Folders List 'If there is no file in the folder, strFile Arry will contain nothing, so close the connection. If StrFileArray Is Nothing Then MessageBox.Show(Dts.Variables("User::Flag").Value.ToString()) ftp.Close() Dts.Variables("User::Flag").Value = 0 'If Files are there, Loop through the StrFileArray arrary and insert into table Else For Each fileName In StrFileArray MessageBox.Show(fileName) If fileName = Dts.Variables("User::FileName").Value.ToString() Then Dts.Variables("User::Flag").Value = 1 MessageBox.Show(Dts.Variables("User::Flag").Value.ToString()) End If Next ftp.Close() End If ' Add your code here ' Dts.TaskResult = ScriptResults.Success End Sub
How to Avoid FTP Task Error when No File Found on FTP Server in SSIS Package
Related Posts / Videos on FTP Task / Script Task
- FTP Task - How to Upload Single File to FTP Server from Local Folder in SSIS Package
- FTP Task - How to Download Single File from FTP Server to Local Folder in SSIS Package
- FTP Task - How to Upload Multiple Files from Local Folder To FTP Server Folder in SSIS Package
- FTP Task - How to Download All the files from FTP Server Folder to Local Folder in SSIS Package
- FTP Task - Filter Files by using WildCard in FTP Task in SSIS Package for downloading
- FTP Task - Delete Specific Files or All Files from FTP Server Folder by using SSIS Package
- FTP Task - Download Only Current Day Files from FTP Server by using FTP Task in SSIS Package
- FTP Task - Create A Directory Folder For Each Day and Load Files on FTP Server by using SSIS Package
- FTP Task and Script Task - How to Avoid FTP Task error when no file found on FTP Server
- FTP Task and Script Task - How to Delete Folder with Files from FTP Server by using SSIS Package
- FTP Task and Script Task - Download a File from FTP Site and Delete after Download in SSIS Package
- FTP Task and Script Task - Sync Local Folder to FTP Server Folder without Upload Existing Files by SSIS Package
- Sync FTP Folder to Local Folder without Downloading Existing Files by using Script Task in SSIS Package
- FTP Task/Script Task - Rename File on FTP Server After Downloading in SSIS Package
- FTP Task/Script Task -How to move file from one folder to another folder on FTP server by using SSIS Package
- FTP Task - Create Local Folder with Date on Daily basis and load files from FTP Folder in SSIS Package
- FTP Task - How to Save Password,User Name,Ftp Server Name as variables/Parameters in SSIS Package to make SSIS Package Dynamic to run in SIT, UAT, QA and Prod.
No comments:
Post a Comment