protected void OnExport(object sender, EventArgs e) { try { string fileName = TBFileName.Text; fileName = Path.ChangeExtension(fileName, "csv"); byte[] fileBytes = null; PalletStacking.Export( DimCase, WeightCase, DimPallet, WeightPallet, MaxPalletHeight, BoxPositions, ChkbMirrorLength.Checked, ChkbMirrorWidth.Checked, ChkbInterlayerBottom.Checked, ChkbInterlayersIntermediate.Checked, ChkbInterlayerTop.Checked, ref fileBytes); if (FtpHelpers.Upload(fileBytes, ConfigSettings.FtpDirectory, fileName, ConfigSettings.FtpUsername, ConfigSettings.FtpPassword)) { ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage", $"alert('{fileName} was successfully exported!');", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage", $"alert('{ex.Message}');", true); } }