/// <summary> /// Function Name : SftpDeleteFile() /// Description : Deletes a given file from a SFTP location. /// </summary> /// <param name="sftpFile">Name of a file to delete from SFTP</param> public void SftpDeleteFile(String sftpFile) { try { if (!this.SftpConnect()) { this.SftpConnect(); if (!this.SftpConnect()) { throw new Exception("Sftp not connected."); } } _objSftpClient.DeleteFile("/" + sftpFile); } catch (Exception ex) { Console.WriteLine("Error while deleting file from SFTP. Error: " + ex); throw new Exception("Error while deleting file from SFTP. Error: " + ex);; } }