/// <summary>If this ProductImage has an Image then save the Image to the file system.</summary> private void SaveImageFile(ProductImage pi, System.Drawing.Image resized, ProductImage.SizeOption size) { if (!Directory.Exists(pi.Product.MetaProduct.Agency.ContentDirectory)) Directory.CreateDirectory(pi.Product.MetaProduct.Agency.ContentDirectory); Contract.Assert(resized != null, "Image file save failed because Image is null."); resized.Save(pi.GetFullyQualifiedFileName(size), System.Drawing.Imaging.ImageFormat.Jpeg); resized.Dispose(); }
private void DeleteProductImageFiles(ProductImage image) { if (File.Exists(image.GetFullyQualifiedFileName(ProductImage.SizeOption.SMALL))) File.Delete(image.GetFullyQualifiedFileName(ProductImage.SizeOption.SMALL)); if (File.Exists(image.GetFullyQualifiedFileName(ProductImage.SizeOption.LARGE))) File.Delete(image.GetFullyQualifiedFileName(ProductImage.SizeOption.LARGE)); }