Hi,
I tried to use transfer options
FileNameCase
in
transferOptions.AddRawSettings
. And it looks like there is no kind of option in referenced .NET WinSCP assembly.
Then I tried to use
sessionOptions.AddRawSettings(@"Interface\CopyParam\FileNameCase", "2")
instead but it seems to be ignored.
When I'm using corresponding option in transfer dialog box it seems to work fine.
Here is a C# code I'm using in SSIS:
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using WinSCP;
namespace ST_6b06a4eeaec549698af87d29422e5606.csproj
{
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.Failure
};
#endregion
public void Main()
{
string winscpPath = @"C:\Program Files (x86)\WinSCP\winscp.exe";
//TEST
string username = "";
string password = "";
string ftpSite = "";
string localPath = @"\\taphil-ww01\www\MSDSDocuments\USA_TEST\GM\";
string remoteFTPDirectory = "/opt/ops/data/non_edi/";
Boolean winSCPLog = true;
string winSCPLogPath = localPath;
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = ftpSite,
UserName = username,
Password = password,
};
using (Session session = new Session())
{
sessionOptions.AddRawSettings(@"Interface\CopyParam\FileNameCase", "2");
if (winSCPLog)
{
session.SessionLogPath = @winSCPLogPath + @"WinscpSessionLog.txt";
session.DebugLogPath = @winSCPLogPath + @"WinscpDebugLog.txt";
}
// Connect
session.Timeout = new TimeSpan(0, 2, 0); // two minutes
session.Open(sessionOptions);
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
transferOptions.OverwriteMode = OverwriteMode.Overwrite;
try
{
session.PutFiles(@localPath + "*.csv", @remoteFTPDirectory + "/feed/", 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).Failure;
return;
}
session.Close();
}
Dts.TaskResult = (int)ScriptResults.Success;
}
}
}
Can you let me know what I'm doing wrong?