473,326 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Filepath lookup from id

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.Drawin g.Imaging.ImageFormat.Jpeg
);
image.Dispose();
}
}
Nov 19 '05 #1
2 878
Sorry ... it should be "if (item != null)" of course ...

/AZ

"Andreas Zita" <an******@student.liu.se> skrev i meddelandet
news:Oo**************@TK2MSFTNGP09.phx.gbl...
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.Drawin g.Imaging.ImageFormat.Jpeg );
image.Dispose();
}
}

Nov 19 '05 #2
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

"Andreas Zita" <an******@student.liu.se> wrote in message
news:Oo**************@TK2MSFTNGP09.phx.gbl...
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.Drawin g.Imaging.ImageFormat.Jpeg );
image.Dispose();
}
}

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Todd Richardson | last post by:
I have written a web form which downloads files to the client automatically. After the download completes, I would like to delete the file that was downloaded. I can't tell how to wait until the...
8
by: Lucas Lemmens | last post by:
Dear pythonians, I've been reading/thinking about the famous function call speedup trick where you use a function in the local context to represent a "remoter" function to speed up the 'function...
9
by: mjakowlew | last post by:
Hi, I'm trying to use some string manipulation from a file's path. filepath='c:\documents\web\zope\file.ext' I need to extract everthing after the last '\' and save it. I've looked around...
9
by: Koen | last post by:
Hi all, My application uses a lot of lookup tables. I've splitted the frontend (forms, reports, etc) from the backend (data). The database has around 10 different users. The values in the...
3
by: my-wings | last post by:
I've been reading about how evil Lookup fields in tables are, but I've got to be missing something really basic. I know this subject has been covered before, because I've just spent an hour or two...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
0
by: darrel | last post by:
when I use 'request.filepage' I get the URL that is shown in the address bar of the browser. The catch is that it will not return the name of the page itself, it if isn't part of the URL (namly...
12
by: snow | last post by:
Hi All, I noticed if file path has a white space, for example "C:\my document \test.txt", the function File.Exists(filePath) always return false in release mode. How could I make this function...
1
by: ateale | last post by:
Hi Guys, Can anyone advise on how to get get a file's filepath via a form? I am working on using a form to allow a user to select a file, then the app uses FTP to transfer the file to the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.