When you press your "Browse" button, you create the Base64 string, and save it to what is (from the name) a text box:
private void buttonBrowse_Click(object sender, EventArgs e) {
OpenFileDialog openDlg = new OpenFileDialog();
openDlg.Filter = "All Supported Files (All Files (*.*)|*.*";
if (openDlg.ShowDialog(this) == DialogResult.OK) {
Cursor = Cursors.WaitCursor;
textBoxAttachFile.Text = openDlg.FileName;
try {
textBoxDescribeIncident.Text = FileToBase64String(openDlg.FileName);
} catch (Exception) {
MessageBox.Show(this, string.Format("An error occurred whilst converting to base-64."),
Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Cursor = Cursors.Default;
}
}
You can access that from your other buttons, provided they are on the same form:
private void buttonCreate_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(textBoxDescribeIncident.Text))
{
MessageBox.Show("Here it is: " + textBoxDescribeIncident.Text);
}
}
If you don't want to display the info in a text box, then declare a private string and put it there instead.
If you need it on a different form, then that's another matter - easy to solve, but different!