J'ai ce code de tâche de script SSIS copié à partir d'un site. J'essaie d'éviter l'erreur FTP a échoué lorsque le dossier est vide. N'a pas besoin d'un fichier de nom spécifique. Le code ci-dessous est pour un nom de fichier spécifique. Comment faire du nom de fichier un caractère générique?Tâche de script SSIS - comment accepter les fichiers génériques dans VB.net
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
N'a pas fonctionné, même résultat. – Jason312
Edited ma réponse je manquais la partie principale :) – Hadi
@ Jason312 attendant votre réponse – Hadi