private void btnUpload_Click(object sender, EventArgs e) { try { ServerManager.UploadFiles(dropped); dropped.Clear(); lstFileToUpload.Items.Clear(); lstBoxFile.DataSource = ServerManager.ReceiveDirectory(); } catch (ArgumentException ex) { MetroFramework.MetroMessageBox.Show(this, "\n\n" + ex.Message, "Errore", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (System.IO.IOException) { MetroFramework.MetroMessageBox.Show(this, "\n\n" + "Impossibile contattare il server", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Allows to manage server's connection /// </summary> private void ManageServer() { try { CheckIP(txtIpServer.Text); ServerManager = new ServerManagement(txtIpServer.Text); ServerManager.SaveFileEvent += ServerManager_SaveFileEvent; lstBoxFile.DataSource = ServerManager.ReceiveDirectory(); lblIP.Text = $"Connesso a : {txtIpServer.Text}"; ToggleFields(Status.Online); } catch (ArgumentException) { lblErroreIP.Visible = true; txtIpServer.WithError = true; lblErroreIP.Text = "Indirizzo IP non valido"; } catch (SocketException) { MetroFramework.MetroMessageBox.Show(this, "\n\nImpossible contattare il server all'indirizzo: " + txtIpServer.Text, "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, "\n\n" + ex.Message, "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error); } }