Beispiel #1
0
        private async Task ListRemoteFiles()
        {
            var files = await FtpService.GetRemoteFileListAsync(this._remotePath.ToString());

            foreach (var item in files)
            {
                this._remoteValue.Add(item);
            }
        }
        private void OnFtpConnectionClosed(bool CleanShutdown)
        {
            ButtonConnectFtp.Invoke(new Action(() =>
            {
                if (!CleanShutdown)
                {
                    ButtonConnectFtp.Enabled = true;
                    ButtonConfig.Enabled     = true;
                }

                ButtonConnectFtp.Text = "Start client";

                ListboxLog.Items.Add(CleanShutdown
                    ? "-- connection ended --"
                    : "-- connection failed --");
                ListboxLog.SelectedIndex = ListboxLog.Items.Count - 1;

                Service = null;
            }));
        }
 private bool StartConnection()
 {
     if (Service == null)
     {
         Service = new FtpService();
         Service.PushNewConfig(FtpConfig);
         Service.OnConnectionOpened   += OnFtpConnectionEstablished;
         Service.OnConnectionClosed   += OnFtpConnectionClosed;
         Service.OnLineSentOrReceived += ParseDebugMessage;
         ButtonConnectFtp.Enabled      = false;
         try { Service.RequestStartService(); return(true); }
         catch (Exception E)
         {
             ButtonConnectFtp.Enabled = true;
             ButtonConnectFtp.Enabled = true;
             MessageBox.Show("Could not connect to the server. Reason: " + E.ToString());
         }
     }
     else
     {
         throw new Exception("connection_exists");
     }
     return(false);
 }