Bu kodlar resmi istediğim boyutta çağırmak için kullandığım kodlar. (Senin kodların modifiye edilmiş hali)
Kod:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Drawing"%>
<script runat="server">
void Page_Load(){
int yeniW = Convert.ToInt16(Request.QueryString["gen"]);
int yeniH = Convert.ToInt16(Request.QueryString["yuk"]);
string adres = Convert.ToString(Request.QueryString["adres"]);
Response.ContentType="image/jpg";
string URI = server.MapPath("images/resim/"+adres);
Bitmap uploadedimage = new Bitmap(URI);
decimal genislik = uploadedimage.Width;
decimal yukseklik = uploadedimage.Height;
decimal gen_oran = (decimal) genislik / yeniW;
decimal yuk_oran = (decimal)yukseklik / yeniH;
int olacak_gen, olacak_yuk;
if (gen_oran > yuk_oran)
{
olacak_gen = (int)(genislik / yuk_oran);
olacak_yuk = yeniH;
}
else {
olacak_gen = yeniW;
olacak_yuk = (int)(yukseklik / gen_oran);
}
System.Drawing.Bitmap DestImage = new System.Drawing.Bitmap(uploadedimage.Width, uploadedimage.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
System.Drawing.Graphics.FromImage(DestImage).DrawImage(System.Drawing.image.FromStream(new System.Net.WebClient().OpenRead(URI)), new System.Drawing.Rectangle(0, 0, uploadedimage.Width, uploadedimage.Height), new System.Drawing.Rectangle(0, 0, uploadedimage.Width, uploadedimage.Height), System.Drawing.GraphicsUnit.Pixel);
System.Drawing.Bitmap imgOutput = new System.Drawing.Bitmap(DestImage,olacak_gen, olacak_yuk);
Graphics myresizer;
myresizer = Graphics.FromImage(imgOutput);
myresizer.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
myresizer.DrawImage(DestImage, 0, 0, olacak_gen, olacak_yuk);
imgOutput.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
imgOutput.Dispose();
}
</script>
Bu kodları kullanarak bir resmi çağırırsam eğer alttaki kodları kullanarak aynı dosyayı silemiyorum. Aslında dosya kullanılmakta olduğu için klasöre girip kendi elimle de silemiyorum.
Kod:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO"%>
<script runat="server">
void Page_Load(){
string adres = Convert.ToString(Request.QueryString["adres"]);
File.Delete(server.MapPath("images/resim/"+adres));
Response.Redirect("anasayfa.aspx");
}
</script>