Exemplo n.º 1
0
        /// <summary>
        /// Function Name : SftpFileUpload()
        /// Description   : This method is used to upload a file from local machine to the SFTP Server.
        /// </summary>
        /// <param name="localLocation">local file path to upload</param>
        public void SftpFileUpload(String localFile, string remortLocation)
        {
            try
            {
                if (!this.SftpConnect())
                {
                    this.SftpConnect();

                    if (!this.SftpConnect())
                    {
                        throw new Exception("Sftp not connected.");
                    }
                }
                Thread.Sleep(5000);
                _objSftpClient.PutFile(localFile, remortLocation);
            }
            catch (Exception ex)
            {
                throw new Exception("Error while uploading file" + localFile + " on SFTP." + ex.Message);
            }
        }