Retrieve Image Full path with its extention

S

Sham

Hai,

I am developing application which handles to create thumbnail form a video
file.
I am successfully created image and i displayed it into browser by,

bit.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);

Now my situation is, i need to save it into my database(sqlserver).
Can anyone tell me how to get that displayed(currently displayed) image file
- full path with its extention(like .gif).

Its urgent ..

Thanks and regards..
Sham
 
M

Marc Gravell

Well, if you have created it in-memory, there might not *be* any file,
except perhaps in the client's cache which you don't have access to.
You might try use Save to write to a MemoryStream, and then from a
MemoryStream you can get the raw byte[] (ToArray etc), which should be
fine for passing as a parameter to a TSQL method, for use in a
varbinary(max) [or "image" pre-SQL2005] column.

(assuming the image isn't too big; for very large byte[] you might
need to "chunk" the work)

Marc
 
M

Marc Gravell

example:

byte[] buffer;
using(MemoryStream ms = new MemoryStream()) {
bit.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
buffer = ms.ToArray();
}
....
SqlCommand cmd = new SqlCommand();
....init
cmd.Parameters.Add(new SqlParameter("blob", Buffer))
....
cmd.ExecuteNonQuery()

where your TSQL uses @blob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top