Terminated by User error and check for functionality

Advertisement

Parag Bangar
Joined:
Posts:
2
Location:
India

Terminated by User error and check for functionality

Hello,

We are using the WinScp dll with one of our .Net application for Moving/Putting/Deleting the files from specific servers.
I would appreciate to have the prompt response to below two queries:

1. At a few times a day it sends us "Terminated by User" error.
FYI, one instance of connection is being closed before creating the new one for next task.
There is nothing with code i feel here, something related to WinScp utility itself is aborting this.
What could be the reason and is there any way to track/debug the same ?

2. Is there any way from where we can list out the latest files from a directory ? Currently we are using RemoteDirectoryInfo.GetListOfFiles() which provides us all the files from a particular directory but I want to list out those which are new ones i.e. uploaded on the directory in last 3 days.

Let me know your suggestions on the same.

Thanks in Advance.

Parag Bangar
E : parag.bangar@ge.com
M : +91-7600701624

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
27,252
Location:
Prague, Czechia

Re: Terminated by User error and check for functionality

1. At a few times a day it sends us "Terminated by User" error.
FYI, one instance of connection is being closed before creating the new one for next task.
There is nothing with code i feel here, something related to WinScp utility itself is aborting this.
What could be the reason and is there any way to track/debug the same ?

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate 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.

2. Is there any way from where we can list out the latest files from a directory ? Currently we are using RemoteDirectoryInfo.GetListOfFiles() which provides us all the files from a particular directory but I want to list out those which are new ones i.e. uploaded on the directory in last 3 days.
There's no RemoteDirectoryInfo.GetListOfFiles.
How to filter the file list depends on a language you are using.

Reply with quote

Parag Bangar
Joined:
Posts:
2
Location:
India

Re: Terminated by User error and check for functionality

martin wrote:

1. At a few times a day it sends us "Terminated by User" error.
FYI, one instance of connection is being closed before creating the new one for next task.
There is nothing with code i feel here, something related to WinScp utility itself is aborting this.
What could be the reason and is there any way to track/debug the same ?

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate 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.

We just have to provide the path of the blank text file where we want the logs , right?

2. Is there any way from where we can list out the latest files from a directory ? Currently we are using RemoteDirectoryInfo.GetListOfFiles() which provides us all the files from a particular directory but I want to list out those which are new ones i.e. uploaded on the directory in last 3 days.
There's no RemoteDirectoryInfo.GetListOfFiles.
How to filter the file list depends on a language you are using.


We are using Ftp methods of winscp.dll with C# code.

Below is the function which provides the list of the files from a particular Ftp location.
What i want is : get the latest uploaded files from this location instead of getting all the files residing there.

public static RemoteDirectoryInfo GetListOfFiles()
{
try
{
RemoteDirectoryInfo remoteDirectory;
SessionOptions sessionOptions = new SessionOptions();
sessionOptions.Protocol = Protocol.Sftp;
sessionOptions.HostName = strPickupFTPHost;
sessionOptions.UserName = strPickupFTPUserName;
sessionOptions.Password = strPickupFTPPassword;
sessionOptions.PortNumber = intPickupPortNumber;
sessionOptions.SshHostKeyFingerprint = strPickupSshHostKey;

if (sessionOptions.Password == null || sessionOptions.Password == "")
{
sessionOptions.SshPrivateKeyPath = strPickUpSshPrivateKeyPath;
}
using (Session session = new Session())
{
session.Open(sessionOptions);
remoteDirectory = session.ListDirectory(clsUtility.strFilePickupLocation);
session.Dispose();
}
return remoteDirectory;
}
}

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,252
Location:
Prague, Czechia

Re: Terminated by User error and check for functionality

We just have to provide the path of the blank text file where we want the logs , right?
The file does not need to exist.

We are using Ftp methods of winscp.dll with C# code.

Below is the function which provides the list of the files from a particular Ftp location.
What i want is : get the latest uploaded files from this location instead of getting all the files residing there.

public static RemoteDirectoryInfo GetListOfFiles()
{
try
{
RemoteDirectoryInfo remoteDirectory;
SessionOptions sessionOptions = new SessionOptions();
sessionOptions.Protocol = Protocol.Sftp;
sessionOptions.HostName = strPickupFTPHost;
sessionOptions.UserName = strPickupFTPUserName;
sessionOptions.Password = strPickupFTPPassword;
sessionOptions.PortNumber = intPickupPortNumber;
sessionOptions.SshHostKeyFingerprint = strPickupSshHostKey;

if (sessionOptions.Password == null || sessionOptions.Password == "")
{
sessionOptions.SshPrivateKeyPath = strPickUpSshPrivateKeyPath;
}
using (Session session = new Session())
{
session.Open(sessionOptions);
remoteDirectory = session.ListDirectory(clsUtility.strFilePickupLocation);
session.Dispose();
}
return remoteDirectory;
}
}

In C# use:
IEnumerable<RemoteFileInfo> lastestFiles = dir.Files.Where(file => file.LastWriteTime > DateTime.Now - TimeSpan.FromDays(3));

Reply with quote

Advertisement

You can post new topics in this forum