NullReferenceException in FtpDLX.PutFile (wodFtpDLX / wodFtpDLX.NET)

by Kurt, (71 days ago)

Hi there

Following code works usually fine. In very rare cases it leads to a NullReferenceException inside of the PutFile call at a customer installation for no obvious reasons. We're using Version 1.8.3.247. Thanks for any hints.

Here's the exception:

System.NullReferenceException: Object reference not set to an instance of an object.
at A.a.n()
at WeOnlyDo.Client.FtpDLX.PutFile(String LocalFile, String RemotePath)

Here's the code. In reality filename changes each time:

using WeOnlyDo.Client;

string filename = "Test.pdf";
string localdir = @"C:\temp\";
string remotedir = @"/Upload/";

using (var ftp = new FtpDLX())
{
ftp.LicenseKey = "#####";

// We don't want to do complex event handling.
ftp.Blocking = true;

ftp.Protocol = Protocols.FTP;
ftp.Hostname = "#####";
ftp.Port = 21;
ftp.Authentication = Authentications.Password;
ftp.Login = "#####";
ftp.Password = "#####";
ftp.Passive = false;
ftp.KeepAlive = 0;
ftp.Timeout = 0;
ftp.Resume = false;

ftp.Connect();

ftp.Timeout = 0;
ftp.ListNames(remotedir);

List<string> files = new List<string>();
foreach (string file in ftp.ListItem.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
{
files.Add(file.ToLowerInvariant());
}

if (!files.Contains(filename.ToLowerInvariant()))
{
ftp.CheckDir(remotedir);
ftp.PutFile(Path.Combine(localdir, filename), remotedir + filename);
}
}


Complete thread: