private void buttonExportLabels_Click(object sender, EventArgs e) { if (listNetworks.SelectedItem != null) { var dialog = new SaveFileDialog { Filter = "CSV|*.csv", DefaultExt = "csv", AddExtension = true }; if (dialog.ShowDialog() == DialogResult.OK) { _service.ExportNetworkVertexLabels(dialog.FileName, (string)listNetworks.SelectedItem); } } }