1. access https://winscp.net

2. Click! [Installation package]

3. You can download setup file

4. Install

5. Proceed with the installation

--------------------------------------------------------------------------------------------------------------------------
.Net assembly
1. You can look "WinSCPnet.dll" after you install WinSCP above.

2. Run the following code
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe" /i WinSCPnet.dll

--------------------------------------------------------------------------------------------------------------------------
Development SSIS
1. You can look "WinSCPnet.dll" after you install WinSCP above.

2. Click "Variables" on new small window after mouse right click at anywhere

3. Make Variables value by your SFTP information

4. Click small icon after double click [Script Task Editor]
And, Select Variables that you made previous

5. Click [Edit Script]

6. Add WinSCPnet.dll into "Reference" (The dll file location = C:\Program Files (x86)\WinSCP )

7. Add below code into Main() method.
// TODO: Add your code here
string winscpPath = Dts.Variables["winSCPPath"].Value.ToString();
string username = Dts.Variables["User::UserName"].Value.ToString();
string password = Dts.Variables["User::Password"].Value.ToString();
string hostName = Dts.Variables["User::HostName"].Value.ToString();
string localPath = Dts.Variables["User::LocalPath"].Value.ToString();
string remoteFTPDirectory = Dts.Variables["User::FTPDirectory"].Value.ToString();
string sshKey = Dts.Variables["SshHostKeyFingerprint"].Value.ToString();
Boolean winSCPLog = (Boolean)Dts.Variables["User::winSCPLog"].Value;
string winSCPLogPath = Dts.Variables["User::winSCPLogPath"].Value.ToString();
SessionOptions sessionOptions = new SessionOptions
{
Protocol =
Protocol.Sftp,
FtpMode = WinSCP.
FtpMode.Active,
FtpSecure =
FtpSecure.None,
HostName = hostName,
UserName = username,
Password = password,
SshHostKeyFingerprint = sshKey,
TimeoutInMilliseconds = 90000
};
try
{
using (Session session = new Session())
{
// WinSCP .NET assembly must be in GAC to be used with SSIS,
// set path to WinSCP.exe explicitly, if using non-default path.
session.ExecutablePath = winscpPath;
session.DisableVersionCheck =
true;
if (winSCPLog)
{
session.SessionLogPath = @winSCPLogPath +
@"WinscpSessionLog.txt";
session.DebugLogPath = @winSCPLogPath +
@"WinscpDebugLog.txt";
}
// Connect
sessionOptions.GiveUpSecurityAndAcceptAnySshHostKey =
true;
session.Open(sessionOptions);
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode =
TransferMode.Binary;
try
{
session.GetFiles(remoteFTPDirectory, localPath,
false, transferOptions);
}
catch (Exception e)
{
Dts.Events.FireError(0,
null,
string.Format("Error when using WinSCP to download file: {0}", e), null, 0);
Dts.TaskResult = (
int)DTSExecResult.Failure;
}
}
Dts.TaskResult = (
int)ScriptResults.Success;
}
catch (Exception ex)
{
Dts.Events.FireError(0,
null,
string.Format("Error when using WinSCP to download file: {0}", ex), null, 0);
Dts.TaskResult = (
int)DTSExecResult.Failure;
}
