protected void bl_procedures_Click(object sender, BulletedListEventArgs e) { try { string path = Server.MapPath("PROCEDURES/" + bl_procedures.Items[e.Index].Text); System.IO.FileInfo file = new System.IO.FileInfo(path); Response.Clear(); Response.AddHeader("Content-Disposition", "inline; filename=" + file.Name); Response.AddHeader("content-length", file.Length.ToString()); Response.ContentType = ReturnExtension(file.Length.ToString()); Response.TransmitFile(file.FullName); //Response.WriteFile(file.FullName); Response.End(); } catch(Exception ex) { Label2.Text = ex.ToString(); } } private string ReturnExtension(string fileExtension) { switch (fileExtension) { case ".htm": case ".html": case ".log": return "text/HTML"; case ".txt": return "text/plain"; case ".doc": return "application/ms-word"; case ".tiff": case ".tif": return "image/tiff"; case ".asf": return "video/x-ms-asf"; case ".avi": return "video/avi"; case ".zip": return "application/zip"; case ".xls": case ".csv": return "application/vnd.ms-excel"; case ".gif": return "image/gif"; case ".jpg": case "jpeg": return "image/jpeg"; case ".bmp": return "image/bmp"; case ".wav": return "audio/wav"; case ".mp3": return "audio/mpeg3"; case ".mpg": case "mpeg": return "video/mpeg"; case ".rtf": return "application/rtf"; case ".asp": return "text/asp"; case ".pdf": return "application/pdf"; case ".fdf": return "application/vnd.fdf"; case ".ppt": return "application/mspowerpoint"; case ".dwg": return "image/vnd.dwg"; case ".msg": return "application/msoutlook"; case ".xml": case ".sdxl": return "application/xml"; case ".xdp": return "application/vnd.adobe.xdp+xml"; default: return "application/octet-stream"; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)