Dev2.Data.PathOperations.Dev2FTPProvider.WriteToSftp C# (CSharp) Method

WriteToSftp() private method

private WriteToSftp ( Stream src, IActivityIOPath dst ) : int
src Stream
dst IActivityIOPath
return int
        int WriteToSftp(Stream src, IActivityIOPath dst)
        {
            var result = -1;
            if(dst != null)
            {
                var sftp = BuildSftpClient(dst);
                if(src != null)
                {
                    using(src)
                    {
                        //byte[] payload = src.ToByteArray();
                        //var tempFileName = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
                        //File.WriteAllBytes(tempFileName, payload);
                        try
                        {
                            var path = ExtractFileNameFromPath(dst.Path);
                            sftp.UploadFile(src, path);
                            result = (int)src.Length;
                            sftp.Disconnect();
                            sftp.Dispose();
                        }
                        catch(Exception e)
                        {

                            Dev2Logger.Log.Debug("Exception WriteToSFTP");
                            Dev2Logger.Log.Debug(e.Message);
                            Dev2Logger.Log.Debug(e.StackTrace);
                            sftp.Disconnect();
                            sftp.Dispose();
                            throw new Exception("File was not created");
                        }
                    }
                }
            }
            return result;
        }