Connect to SFTP using C#

Yes, this happened. We needed to connect to an SFTP server using C#

Shoutout to Luke for this one, I appreciate it.

 //******** method that will connect to an sftp server
//**** variables are set in constants in the web config
        static private void Connect2SFTP()
        {
            try
            {
                PrivateKeyFile keyfile = new PrivateKeyFile(privkeypath);
                var keyfiles = new[] { keyfile };
                var authmethods = new List<AuthenticationMethod> { new PrivateKeyAuthenticationMethod(username, keyfiles) };
                var connectionInfo = new ConnectionInfo(host, port, username, authmethods.ToArray());
                using (var client = new SftpClient(connectionInfo))
                {
                    client.Connect();
                    //client.ChangeDirectory(remoteDir);

                    client.Disconnect();
                }
            } catch (Exception e)
            {
                using (StreamWriter logFile = new System.IO.StreamWriter(AWARDSPRINGLOG, true))
                {
                    logFile.WriteLine(DateTime.Now.ToString() + ": ERROR during Award Spring File Creation");
                    logFile.WriteLine(DateTime.Now.ToString() + " " + e.Message.ToString() + " " + e.StackTrace.ToString());
                }
                throw new Exception(e.Message);
            }
          

        }
        //-------------------------
    }