Topic "ArgumentNullException: Value cannot be null. Parameter name: path1"

Author Message
Destructor83

Guest


This is my code on c#

try
{
string server = ConfigurationManager.AppSettings["server"];
string user = ConfigurationManager.AppSettings["user"];
string password = ConfigurationManager.AppSettings["password"];
string pathToFolder = ConfigurationManager.AppSettings["pathToFolder"];
SessionOptions options = new SessionOptions();
options.HostName = server;
options.Password = password;
options.Protocol = Protocol.Scp;
options.Timeout = TimeSpan.FromSeconds(20);
options.UserName = user;
options.SshHostKeyFingerprint = ""; //I don't use security code
using (WinSCP.Session session = new WinSCP.Session())
{
// Connect
session.Open(options);

// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;

TransferOperationResult transferResult;
transferResult = session.PutFiles(@"d:\toupload\*", "/home/user/", false, transferOptions);

// Throw on any error
transferResult.Check();

// Print results
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
}
}
return true;
}
catch (Exception ex)
{
Logs.Error(ex.ToString());
return false;
}

My application works on mono/linux and I don't use security code

Exception throws when I try to open session.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25748
Location: Prague, Czechia
Please attach a full exception callstack and full debug log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.DebugLogPath. 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.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License