Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: System.AggregateException

Show us a full exception callstack, any inner exceptions (including callstacks) and debug log (Session.DebugLogPath).
balderstonb

System.AggregateException

I'm getting a System.AggregateException at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) with the following code (passwords and paths omitted):

SessionOptions sessionOptions = new SessionOptions

{
   Protocol = Protocol.Sftp,
   HostName = "",
   UserName = "",
   Password = "",
   SshHostKeyFingerprint = ""
};

using (Session session = new WinSCP.Session())
{
   session.Open(sessionOptions);

   TransferOptions transferOptions = new TransferOptions()
   {
      TransferMode = TransferMode.Automatic
   };

   IEnumerable<RemoteFileInfo> files = session.EnumerateRemoteFiles("", "*.xml", EnumerationOptions.None);

   string localDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
   Directory.CreateDirectory(localDir);

   foreach (RemoteFileInfo file in files)
   {
      string localFile = Path.Combine(localDir, file.Name);
      TransferOperationResult transferResult = session.GetFiles(file.FullName, localFile, false, transferOptions);

      if (transferResult.IsSuccess) //Exception thrown
      {

      }
   }
}


What could be causing this? Thanks for the assistance.