PDA

View Full Version : out of memory



hamix666
پنج شنبه 25 مهر 1398, 18:43 عصر
سلام به اساتید
من در هنگام ذخیره 15 تا عکس در بانک به خطای out of memory می خورم چی کار باید انجام بدم


AminTebBl.ImagBl _imageBl = new ImagBl();


var Setting = _settingBl.GetSetting();
List<Model.Models.tbImage> _lstimag = new List<tbImage>();
var path = Setting.UrlPic;
var destinationFile = _parvande.GetParvande(parvandenum);
string sourceFile = path + "\" + destinationFile.UrlPic + @"\Other";
DirectoryInfo sourceDirInfo = new DirectoryInfo(sourceFile);
_imageBl.DeleteImage(parvandenum);
foreach (FileInfo sourceFileInfo in sourceDirInfo.GetFiles())
{
string fileName = sourceFileInfo.Name;
string destFile =
Path.Combine(
path + "\" + destinationFile.UrlPic + @"\Other", fileName);


#region ذخیره در دیتابیس
if (AminTebCommon.ClsLogin.Company.ID != 1)
{


string base64String = null;
byte[] imageBytes;
using (System.Drawing.Image image = System.Drawing.Image.FromFile(destFile))
{
using (MemoryStream m = new MemoryStream())
{
image.Save(m, image.RawFormat);
imageBytes = m.ToArray();


}
}
var _new = new Model.Models.tbImage()
{
IDParvande = destinationFile.ID,
//ImageFile = Pic_From_Db,
NameFile = sourceFileInfo.Name,
FormatFile = "." + fileName.Split('.')[1],
ImageFileBase = imageBytes,
};
_imageBl.SaveImage2(_new);







}


#endregion


}

ROSTAM2
پنج شنبه 25 مهر 1398, 20:02 عصر
سلام. منم به اساتید سلام میکنم؛ این خطا وقتی نمایش داده می شه در این مورد که حجم فایل تصویر زیاده. برای این کار می تونی از امکانات تغییر سایز تصویر استفاده کنی بعد ذخیره کنی.