what changes i need to make to send all files from a folder
Following code works perfectly for sending one file, i need to send all the files in folder.
i know its easy but i am not .net developer....
thanks in advance.......
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Public Sub Main()
Try
'Create the connection to the ftp server
Dim cm As ConnectionManager = Dts.Connections.Add("FTP")
'Set the properties like username & password
cm.Properties("ServerName").SetValue(cm, "xxxx")
cm.Properties("ServerUserName").SetValue(cm, "xxxx")
cm.Properties("ServerPassword").SetValue(cm, "xxxx")
cm.Properties("ServerPort").SetValue(cm, "21")
cm.Properties("Timeout").SetValue(cm, "0") 'The 0 setting will make it not timeout
cm.Properties("ChunkSize").SetValue(cm, "1000") '1000 kb
cm.Properties("Retries").SetValue(cm, "1")
'create the FTP object that sends the files and pass it the connection created above.
Dim ftp As FtpClientConnection = New FtpClientConnection(cm.AcquireConnection(Nothing))
'Connects to the ftp server
ftp.Connect()
'Build a array of all the file names that is going to be FTP'ed (in this case only one file)
Dim files(0) As String
files(0) = "\\usr-p-filesrv\shared\Veeva\SQL-Skonda\NovaNordisk\PDI_NN_Recipient_20120718.xls"
'ftp the file
'Note: I had a hard time finding the remote path directory. I found it by mistake by creating both the FTP connection and task in the SSIS package and it defaulted the remote path setting in
the FTP task.
ftp.SendFiles(files, "/veeva/VeevaShipments/NewFolder", True, False) ' the True makes it overwrite existing file and False is saying that it is not transferring ASCII
ftp.Close()
Catch ex As Exception
Dts.TaskResult = Dts.Results.Failure
End Try
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
July 18th, 2012 2:18pm
if you don't know .Net, why not use the
FTP Task with a wildcard (* or ?) to select all files in a folder?
Or if you want to use .Net you could post a reply in this thread:
http://social.msdn.microsoft.com/forums/en-US/sqlintegrationservices/thread/2b7cf6b5-d16d-44cd-954d-68e9ba98ee91/
Please mark the post as answered if it answers your question | My SSIS Blog:
http://microsoft-ssis.blogspot.com |
Twitter
Free Windows Admin Tool Kit Click here and download it now
July 18th, 2012 4:10pm
i know how to use FTP task...the link which u posted is good for one file......i copied the code from the same link.....
July 18th, 2012 4:57pm