private bool GenerateFileFromCP(string fileName, out string msg) { try { msg = string.Empty; var b64Str = Clipboard.GetText(); var fromClipboardStr = StringCompression.Decompress(b64Str); Byte[] bytes = Convert.FromBase64String(fromClipboardStr); File.WriteAllBytes(fileName, bytes); return(true); } catch (Exception ex) { msg = ex.Message; return(false); } }
private void button3_Click(object sender, EventArgs e) { try { if (File.Exists(filePath)) { var bytes = File.ReadAllBytes(filePath); var base64String = Convert.ToBase64String(bytes); var clipboardStr = StringCompression.Compress(base64String); Clipboard.SetText(clipboardStr); MessageBox.Show("Done! \n Open the application on the other host to receive it ", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Please select a file ", "Select file", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }