List Info

Thread: Too many temp files




Too many temp files
user name
2006-03-31 20:17:04
I've got an app that's spitting out temp files like crazy.
I wonder if
anyone here can help (or if not, point me to a
forum/discussion list that
can).

Here's what my app does. First, download the image:

internal void download() {
    // do an http get on _uri, straight into a
system.graphics.image object
    System.Net.WebClient webclient = new
System.Net.WebClient();
    _img = Image.FromStream(webclient.OpenRead(_uri));
}

Then make a bunch of sizes for it. Here's the resizing
method:

private Bitmap ResizeImageCrop(Image image, Size maxSize) {
    // [...] snip a lot of math for determining the output
size
    Bitmap bitmap = new Bitmap(maxSize.Width,
maxSize.Height,
image.PixelFormat);
    Graphics graphicsImage = Graphics.FromImage(bitmap);
    graphicsImage.SmoothingMode = SmoothingMode.HighQuality;
    graphicsImage.InterpolationMode =
InterpolationMode.HighQualityBicubic;
    graphicsImage.FillRectangle(Brushes.White, new
Rectangle(-1, -1,
maxSize.Width + 1, maxSize.Height + 1));
    graphicsImage.DrawImage(image, targetCropLeft,
targetCropTop,
targetSize.Width, targetSize.Height);
    graphicsImage.Dispose();
    return bitmap;
}

And here's the call to that Then make a bunch of sizes for
it. Here's one:

ResizeImageCrop((Image)_img.Clone(), newSize).Save(folder +
this._Gallery_Image, jpegCodec, jpegParams);


So, somewhere in there, it's making a copy of the image and
saving it into
the c:\windows\temp\ folder. I can't tell if it's the
WebClient during
download, or if it's the Graphics when it draws, or if
it's the Image when
it saves. Does anybody know what I can do to (a) prevent the
temp file from
being created, (b) automatically delete the temp file, like
a Dispose() I
left somewhere, or (c) find the file it created and delete
it manually? I
searched the docs but they're fairly cryptic, and silent on
the subject.

thanks!
-nathan strutz
http://www.dopefly.com/


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:44:2371
Archives: 
http://www.houseoffusion.com/cf_lists/threads.cfm/44
Subscription: http
://www.houseoffusion.com/lists.cfm/link=s:44
Unsubscribe: http://www.houseoffusion.com/cf_lists/u
nsubscribe.cfm?user=22184.15789.44
Donations & Support: http://www.h
ouseoffusion.com/tiny.cfm/54
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )