Filepath lookup from id

A

Andreas Zita

Hi

The code below takes an id and return the corresponding image-stream. My
Album-class scans the provided dir for images and tags them with id and
filePath on server. In my current approach the m_album is re-generated each
time a request is made. However I would like it to be generated only once
when first run and then always be available on the server ... any ideas on
how a could speed this thing up?

/Andreas Zita

private void Page_Load(object sender, System.EventArgs e)
{
m_album = new Album(Server.MapPath("Data"));
int id = Int32.Parse(Request.QueryString["id"]);
Item item = m_album.FindItemById(id);
if (item == null)
{
System.Drawing.Image image = System.Drawing.Image.FromFile(item.Path);
Response.ContentType = "image/jpeg";

thumbNail.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg
);
image.Dispose();
}
}
 
E

Eliyahu Goldin

What is the problem? Is m_album.FindItemById slow? All you need to keep is
the item id and the path. You can make a little table in database if you
have one or a lookup file otherwise.

Eliyahu
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top