I am trying to open the file in browser (browser will give me Open/Save dialog box). This is what I am using
FileStream MyFileStream = new FileStream(@"C:\bb.txt", FileMode.Open);
long FileSize;
FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length);
MyFileStream.Close();
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("content-disposition", "inline;attachment; filename=MyPDF.txt");
Response.BinaryWrite(Buffer);
It is writing the browser response to the file also. I am using this code on a web page and when it is showing that file, browser also writing the Page Html also into the txt file.
Add
Response.End()