private void buttonSaveAsPDF_Click(object sender, EventArgs e) { using (ServiceReference.ServiceClient client = new ServiceReference.ServiceClient()) { byte[] result = client.GenerateSavedReportAsPDF(1); if (result == null || result.Length == 0) { MessageBox.Show("Something wrong!"); } else { if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { File.WriteAllBytes(saveFileDialog.FileName, result); } } } }