2010-05-19 8 views
0

Я немного забывчивый сделал это много раз и не может найти код от последнего времени я сделал это как я получаю его размер больше, чем одна картинкикак изменить размер изображения

мне нравится это

Guid imageName; 
imageName = Guid.NewGuid(); 
string storePath = Server.MapPath("~") + "/MultipleUpload"; 
if (!Directory.Exists(storePath)) 
    Directory.CreateDirectory(storePath); 
hif.PostedFile.SaveAs(storePath + "/" + Path.GetFileName(hif.PostedFile.FileName)); 

string tempPath = "Gallery"; 
string imgPath = "Galleryt"; 
string savePath = Path.Combine(Request.PhysicalApplicationPath, tempPath); 
string TempImagesPath = Path.Combine(savePath, imageName + hif.PostedFile.FileName); 
string imgSavePath = Path.Combine(Request.PhysicalApplicationPath, imgPath); 
string ProductImageNormal = Path.Combine(imgSavePath, "t__" + imageName + hif.PostedFile.FileName); 
string extension = Path.GetExtension(hif.PostedFile.FileName); 
switch (extension.ToLower()) 
    { 
     case ".png": goto case "Upload"; 
     case ".gif": goto case "Upload"; 
     case ".jpg": goto case "Upload"; 
     case "Upload": hif.PostedFile.SaveAs(TempImagesPath); 
      ImageTools.GenerateThumbnail(TempImagesPath, ProductImageNormal, 250, 350, true, "heigh"); 
      Label1.Text = ""; 
      break; 
    } 
+5

Возможно, используя петлю ... –

+0

кто-нибудь для SOC/SRP? –

+0

Какова цель тега 'e'? – RichK

ответ

0

я узнал себя , но все равно спасибо за глядя

, но теперь у меня есть еще одна проблема я не буду сохранить исходный файл на странице его следует исключить еще раз, когда она будет закончена размер Если я просто удалить его сразу после того, в коде с

File.Delete(Server.MapPath("~/Gallery/" + imageName + hif.PostedFile.FileName)); 

так он говорит, что он не может удалить файл, так как он используемый другим процессом.

     string storePath = Server.MapPath("~") + "/MultipleUpload"; 
         if (!Directory.Exists(storePath)) 
          Directory.CreateDirectory(storePath); 

         string tempPath = "Galleryt"; 
         string imgPath = "Gallery"; 
         string savePath = Path.Combine(Request.PhysicalApplicationPath, tempPath); 
         string imgSavePath = Path.Combine(Request.PhysicalApplicationPath, imgPath); 
         string imgSavePath2 = Path.Combine(Request.PhysicalApplicationPath, imgPath); 
         string ProductImageNormal = Path.Combine(imgSavePath, imageName + hif.PostedFile.FileName); 
         string ProductImagetemp = Path.Combine(savePath, "t__" + imageName + hif.PostedFile.FileName); 
         string ProductImagetemp2 = Path.Combine(imgSavePath2, "b__" + imageName + hif.PostedFile.FileName); 
         string extension = Path.GetExtension(hif.PostedFile.FileName); 

         switch (extension.ToLower()) 
         { 
          case ".png": goto case "Upload"; 
          case ".gif": goto case "Upload"; 
          case ".jpg": goto case "Upload"; 
          case "Upload": hif.PostedFile.SaveAs(ProductImageNormal); 
           ImageTools.GenerateThumbnail(ProductImageNormal, ProductImagetemp, 600, 600, true, "heigh"); 
           ImageTools.GenerateThumbnail(ProductImageNormal, ProductImagetemp2, 250, 350, true, "heigh"); 

           Label1.Text = ""; 
           break; 
          default: 
           Label1.Text = "Status: Denne filtype er ikke tilladt"; 
           return; 

         } 
Смежные вопросы