当超过1366文件扫描之后,它将引发错误 代码计算所选文件夹上的tif文件 代码:
int mergeTiffPages(string[] path)
{
Cursor.Current = Cursors.WaitCursor;
string[] sa = path;
int frame = 0;
Bitmap bitmap;
int count = 0 ;
foreach (string s in sa)
{
{
try
{
bitmap = (Bitmap)Image.FromFile(s);//Its will raise an error OutOf Memory
if (bitmap != null)
{
count = bitmap.GetFrameCount(FrameDimension.Page);
frame += count;
bitmap = null;
count = 0;
}
}
catch(Exception ex)
{
MessageBox.Show("Not TIFF image file. please select the folder in which tif file is available", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
cntval.Text = frame.ToString();
Cursor.Current = Cursors.Default;
return 1;
}
在函数的路径上设置所有图像文件的数组
Error:OutOfMemory
答案 0 :(得分:1)
使用此:
using (bitmap = (Bitmap)Image.FromFile(s))
{
...
}