private async void btRemoveFile_Click(object sender, EventArgs e) { int selectedFileIndex = lbAttachedFiles.SelectedIndex; if (selectedFileIndex > -1 && selectedFileIndex < lbAttachedFiles.Items.Count) { string fileInfo = lbAttachedFiles.Items[selectedFileIndex].ToString(); int fileId = fileSharingClient.GetFileIdByFilesToSend(fileInfo); if (fileId != -1) { await fileSharingClient.DeleteFile(fileId, FileSharingServerUrl); } } }
private async void DeleteFileButton_Click(object sender, EventArgs e) { try { var selectedFileIndex = FilesToLoadListBox.SelectedIndex; if (selectedFileIndex > -1 && selectedFileIndex < FilesToLoadListBox.Items.Count) { var fileInfo = FilesToLoadListBox.Items[selectedFileIndex].ToString(); var fileId = fileSharingClient.GetFileIdByInfoInFilesToLoadList(fileInfo); if (fileId != -1) { await fileSharingClient.DeleteFile(fileId, FileSharingServerUrl); } else { MessageBox.Show("Id файла с таким названием не найдено!", "Error!"); } } } catch (Exception ex) { MessageBox.Show("Исключение: " + ex.Message); } }