Exemplo n.º 1
0
        public MemoryStream ReadFile1(HttpResponse response)
        {
            response.StatusCode = 200;
            Stream       strm     = new FileStream("F:/tmp/dummy.csv", FileMode.Open);
            BinaryReader Rdr      = new BinaryReader(strm);
            List <Byte>  returned = new List <Byte>();

            while (true)
            {
                try
                {
                    Byte read = Rdr.ReadByte();
                    returned.Add(read);
                }
                catch (System.IO.EndOfStreamException)
                {
                    Rdr.Close();
                    break;
                }
            }
            response.AddResponseHeader("Content-Disposition", "attachment;filename=" + "dummy.csv");
            return(new MemoryStream(returned.ToArray()));
        }