private void btnAddFile_Click(object sender, EventArgs e) { try { using (var dialog = new OpenFileDialog()) { if (dialog.ShowDialog() == DialogResult.OK) { var fileContent = File.ReadAllBytes(dialog.FileName); var file = new Model.File { Name = Path.GetFileName(dialog.FileName), Owner = new User { Id = _userId } }; var fileId = _client.CreateFile(file); _client.UploadFileContent(fileId, fileContent); RefreshFileList(); MessageBox.Show($"Файл {file.Name} успешно загружен", "Загрузка файла", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception exception) { MessageBox.Show($"Не удалось загрузить файл, текст ошибки: {Environment.NewLine}{exception.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAddFile_Click(object sender, EventArgs e) { try { using (var dialog = new OpenFileDialog()) { if (dialog.ShowDialog() == DialogResult.OK) { var fileContent = File.ReadAllBytes(dialog.FileName); var file = new Model.File { Name = Path.GetFileName(dialog.FileName), Owner = _client.GetUser() }; var fileId = _client.CreateFile(file); _client.UploadFileContent(fileId, fileContent); RefreshFileList(); MessageBox.Show($"File {file.Name} was added successfully", "File Download", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception exception) { MessageBox.Show($"File was not added. Error message: {Environment.NewLine}{exception.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }