Download a file Programmatically C#
Use the following Code-Snippet to Download a particular file-type Programmatically:
FileStream fs; object strPath = "C:\\My External\\File Path\\"; string strFileName = "7f0873f1.mp3"; // Check Validation Here if (true) { fs = File.Open(strPath + strFileName, FileMode.Open); byte[] bytBytes = new byte[fs.Length]; fs.Read(bytBytes, 0, Convert.ToInt32(fs.Length)); fs.Close(); Response.AddHeader("Content-disposition", "attachment; filename=" + strFileName); Response.ContentType = "application/octet-stream"; Response.BinaryWrite(bytBytes); Response.End(); } else { // Error }
This is an excellent component for verifying email addresses:
ReplyDeletehttp://www.kellermansoftware.com/p-37-net-email-validation.aspx