Beispiel #1
0
        public void StartPsftp(ConnectionInfo connectionInfo)
        {
            var fileName = Path.Combine(PathHelper.StartupPath, PsftpLocation);
            var args     = ArgumentsBuilder.BuildPsftpArguments(
                connectionInfo,
                PrivateKeyStorage.Create(connectionInfo.PrivateKeyData).Filename);

            Process.Start(fileName, args);
        }
        public void Open()
        {
            try
            {
                this.CheckConsistency();

                this.passwordProvided         = false;
                this.passphraseForKeyProvided = false;
                this.HasForwardingFailures    = false;
                this.State = ConnectionState.Opening;
                this.multilineErrorText.Clear();

                string privateKeyFileName = null;
                if (this.Info.AuthType == AuthenticationType.PrivateKey)
                {
                    privateKeyFileName = PrivateKeyStorage.Create(this.Info.PrivateKeyData).Filename;
                }

                var puttyArguments = ArgumentsBuilder.BuildPuttyArguments(this.Info, false, privateKeyFileName);
                this.process = new Process
                {
                    StartInfo =
                    {
                        FileName               = PLinkLocation,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        RedirectStandardError  = true,
                        RedirectStandardOutput = true,
                        RedirectStandardInput  = true,
                        Arguments              = puttyArguments
                    }
                };

                this.process.Exited             += (s, a) => this.Close();
                this.process.ErrorDataReceived  += this.HandleErrorData;
                this.process.OutputDataReceived += this.HandleOutputData;
                this.process.Start();
                this.process.BeginErrorReadLine();
                this.process.BeginOutputReadLine();

                this.process.StandardInput.AutoFlush = true;
            }
            catch (Exception ex)
            {
                this.PublishFatalError(ex.Message);
                this.Close();
            }
        }