以流方式打开文件并输出到网页

 FileStream fs = new FileStream(@"C:\annex\Picture\SmallPicture\T20070725152344191002.jpg", FileMode.Open, FileAccess.Read);
        byte[] mydata = new byte[fs.Length];
        int Length = Convert.ToInt32(fs.Length);
        fs.Read(mydata, 0, Length);
        fs.Close();
        Response.ClearContent();
        Response.ContentType = "application/octet-stream";
        this.Response.OutputStream.Write(mydata, 0, Length);
        this.Response.End();
posted @ 2007-07-25 19:32  しovのんeТs  阅读(368)  评论(0编辑  收藏  举报