/ Published in: C#
Useful for sending files past filters via email.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
private void btnEncode_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtInFile.Text)) { FileMode.Open, FileAccess.Read); fs.Read(filebytes, 0, Convert.ToInt32(fs.Length)); string encodedData = Convert.ToBase64String(filebytes, Base64FormattingOptions.InsertLineBreaks); txtEncoded.Text = encodedData; } } private void btnDecode_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtOutFile.Text)) { byte[] filebytes = Convert.FromBase64String(txtEncoded.Text); FileMode.CreateNew, FileAccess.Write, FileShare.None); fs.Write(filebytes, 0, filebytes.Length); fs.Close(); } }