locked
About MemoryStream And Files RRS feed

  • Question

  • User-24958776 posted
    Precondition: ADODB.RecordSet arData; in arDat a field type is image; A file named aaa.txt; System.IO.MemoryStream msFile = new System.IO.MemoryStream(); Querstion: How 1.Copy the image-field to aaa.txt(local); 2.Add the aaa.txt to the msFile; 3.Add the aaa.txt to the image-field; 4.Add the msFile to the image-field; Thanks.
    Friday, March 26, 2004 3:52 AM

All replies

  • User-1391363652 posted
    You don't really need a temporary file. That's the whole point of using MemoryStream. Suppose you have an image in a byte array. You can stream an image to the response stream like this: app.Context.ClearError (); app.Context.Response.Expires = 0; app.Context.Response.Buffer = true; app.Context.Response.Clear (); MemoryStream memStream = new MemoryStream ((byte [])arr); memStream.WriteTo (app.Context.Response.OutputStream); memStream.Close (); app.Context.Response.ContentType = "image/gif"; app.Context.Response.StatusCode = 200; app.Context.Response.End (); } No need to create an imge file on disk. Does this answer your question?
    Friday, March 26, 2004 11:12 AM
  • User-24958776 posted
    Thank you I get your mind,but this question is in the WebForm :) and the aaa.txt i need it. Sorry,i'm using Delphi before C#, in Delphi,that's so easy to get. I can use TBlob(),LoadFromStream(),can SaveToStream()...but i don't know how can i get it in C#. Thanks again.
    Friday, March 26, 2004 1:09 PM