byte[] binfile = item.File.OpenBinary(); FileStream fstream = new FileStream(@"E:\Oliver\" + item.File.Name, FileMode.Create, FileAccess.ReadWrite); //fstream.Write(binfile, 0, binfile.Length); if (Response.IsClientConnected) { int length = fstream.Read(binfile, 0, binfile.Length); Response.OutputStream.Write(binfile, 0, binfile.Length); Response.Flush(); } fstream.Close();
private void ShowDocument(string fileName, byte[] fileContent) { //Split the string by character . to get file extension type string[] stringParts = fileName.Split(new char[] { '.' }); string strType = stringParts[1]; Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.AddHeader("content-disposition", "attachment; filename=" + fileName); //Set the content type as file extension type Response.ContentType = strType; //Write the file content this.Response.BinaryWrite(fileContent); this.Response.End(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)