<PackageReference Include="Relativity.Transfer.Client" Version="7.0.8" />

TempFileDeleter

using System; using System.Diagnostics; using System.IO; using System.Threading; namespace Aspera.Transfer { internal class TempFileDeleter { private readonly Process _ascp; private readonly string _tempFileName; private readonly FileTransferSession _session; public TempFileDeleter(Process process, string tempFileName, FileTransferSession session) { _ascp = process; _tempFileName = tempFileName; _session = session; new Thread(WaitForCleanup).Start(); } private void WaitForCleanup() { _ascp.WaitForExit(); try { File.Delete(_tempFileName); } catch (Exception ex) { Logger.Log(TraceEventType.Verbose, "Failed to clean file " + _tempFileName + ": " + ex.ToString()); } if (_ascp.ExitCode != 0) { _session.errNum = _ascp.ExitCode; _session.errDescription = _ascp.StandardError.ReadToEnd(); _session.state = SessionState.FAILED; Logger.Log(TraceEventType.Error, "ascp process exited with error: " + _session.errDescription + " (Exit value: " + _session.errNum + ")"); _session.handleAscpCrash(); } } } }