MEmory stream, file stream

  • Thread starter Thread starter Pums
  • Start date Start date
P

Pums

While retriving an image i came across two streams
Filestream and Memorystream. can anyone guide me when
should i use which?
 
Pums said:
While retriving an image i came across two streams
Filestream and Memorystream. can anyone guide me when
should i use which?

Well, what exactly do you want to do? A FileStream reads/writes from/to
a file; a MemoryStream reads/writes from/to memory.
 
Actually i am retriving an image from sql server. It's in
binary. i want to assign that image to a picturebox. now
for that i can create write that binary as a byte stream
in memory stream or i can create a temporary file by
using filestream. Sometimes u might now have writable
permisssion to a folder. in that case you can't create
that file by using filestream.

So, my point was to exactly know the scenerio where we
should use filestream or memorystream only. Right now for
my application i can use both. but, there may be cases
where i need to use any one of them. I wanted to know
those cases.
 
Pums said:
Actually i am retriving an image from sql server. It's in
binary. i want to assign that image to a picturebox. now
for that i can create write that binary as a byte stream
in memory stream or i can create a temporary file by
using filestream. Sometimes u might now have writable
permisssion to a folder. in that case you can't create
that file by using filestream.

So, my point was to exactly know the scenerio where we
should use filestream or memorystream only. Right now for
my application i can use both. but, there may be cases
where i need to use any one of them. I wanted to know
those cases.

I would personally go for a MemoryStream here - I can't see that using
a FileStream buys you anything, really. In terms of cases where you
need to use one in particular - if you don't want a file involved, use
a MemoryStream, and if you do, use a FileStream.
 
Back
Top