ArgumentNullException: Value cannot be null. Parameter name: path1

Advertisement

Destructor83
Guest

ArgumentNullException: Value cannot be null. Parameter name: path1

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.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
29,033
Location:
Prague, Czechia

Re: ArgumentNullException: Value cannot be null. Parameter name: path1

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.

Reply with quote

Advertisement

You can post new topics in this forum