transferOptions.AddRawSettings

Advertisement

ITG
Guest

transferOptions.AddRawSettings

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())
            {
                
                session.ExecutablePath = winscpPath;
                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?

Reply with quote

Advertisement

ITG
Guest

DEBUG and SESSION logs

I'm attaching logs.

Sorry but I changed some sensitive parts.
  • WinscpSessionLog.txt (6.67 KB, Private file)
  • WinscpDebugLog.txt (48.83 KB, Private file)

Reply with quote

ITG
Guest

Thanks for reply Martin,

I'm using 5.13.9 version of EXE and file version 1.5.7.9343 of DLL.
What you can see in my code attached im using:
session.AddRawConfiguration(@"Interface\CopyParam\FileNameCase", "2");
but files are being sent without case change and I don't get why..

When I tried to add 5.14 or BETA 5.14.2 to GAC with .NET 2.0 it says:

This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Did you use newer runtime or my system is going crazy?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
31,037
Location:
Prague, Czechia

ITG wrote:

I'm using 5.13.9 version of EXE and file version 1.5.7.9343 of DLL.
What you can see in my code attached im using:
session.AddRawConfiguration(@"Interface\CopyParam\FileNameCase", "2");
but files are being sent without case change and I don't get why..
Please attach a full session log file showing the problem (using the latest version of WinSCP). Also there's no "code attached".

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

Advertisement

You can post new topics in this forum