private void btnFileDownload_Click(object sender, EventArgs e) { int transfPort = 0; if (!Int32.TryParse(txtTransferPort.Text, out transfPort)) { MessageBox.Show("Please put in a valid port before requesting a file.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (listFiles.SelectedItems.Count != 1) { return; } if (listFiles.SelectedItems[0].SubItems[1].Text != "FILE") { return; } SaveFileDialog sfd = new SaveFileDialog(); if (sfd.ShowDialog() == DialogResult.OK) { FileServer fs = new FileServer(this, ip, transfPort, sfd.FileName, String.Empty); fs.StartListeningForFile(); SendASCII("SEND_FILE<%SEP%>" + txtLocation.Text + listFiles.SelectedItems[0].SubItems[0].Text + "<%SEP%>" + txtTransferPort.Text); SetText(lblStatus, "REQUEST sent. Awaiting for initial data."); } }
private void btnFileDownload_Click(object sender, EventArgs e) { int transfPort = 0; if (!Int32.TryParse(txtTransferPort.Text, out transfPort)) { MessageBox.Show("Please put in a valid port before requesting a file.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (listFiles.SelectedItems.Count != 1) return; if (listFiles.SelectedItems[0].SubItems[1].Text != "FILE") return; SaveFileDialog sfd = new SaveFileDialog(); if (sfd.ShowDialog() == DialogResult.OK) { FileServer fs = new FileServer(this ,ip, transfPort, sfd.FileName, String.Empty); fs.StartListeningForFile(); SendASCII("SEND_FILE<%SEP%>" + txtLocation.Text + listFiles.SelectedItems[0].SubItems[0].Text + "<%SEP%>" + txtTransferPort.Text); SetText(lblStatus, "REQUEST sent. Awaiting for initial data."); } }