好象不是上面一段的问题应该是这一段出问题了
Image img = Image.FromFile(file);
ImageFormat[] imgf = {ImageFormat.Jpeg, ImageFormat.Bmp, ImageFormat.Gif, ImageFormat.Png};
string[] imgs ={".jpg", ".bmp", ".gif", ".png"};
string f = file.ToLower();
bool found=false;
for(int i=0;i<imgs.Length;i++)
{
if(img.RawFormat.Equals(imgf[i]))
{
if(!f.EndsWith(imgs[i]))
{
RightType=imgs[i];
return false;
}
found = true;
break;
}
}
img.Dispose();
return true;
Image img = Image.FromFile(file);
ImageFormat[] imgf = {ImageFormat.Jpeg, ImageFormat.Bmp, ImageFormat.Gif, ImageFormat.Png};
string[] imgs ={".jpg", ".bmp", ".gif", ".png"};
string f = file.ToLower();
bool found=false;
for(int i=0;i<imgs.Length;i++)
{
if(img.RawFormat.Equals(imgf[i]))
{
if(!f.EndsWith(imgs[i]))
{
RightType=imgs[i];
return false;
}
found = true;
break;
}
}
img.Dispose();
return true;
解决方案 »
- 关于文件流写入覆盖掉的问题,详请进。
- 为什么一刷新会自动添加数据
- C#的WinForm开发问题:如果提取WebBrowser中加载的某个图片流到某个PictureBox?
- C#编程中界面最大化时各控件的比例设置
- 我在调用自己编写的其他类的时候,为什么里面申明的static变量的值在第2次调用时等于第1次的结果啊?
- 请高手帮忙,大型文件处理!
- C#中怎么用MS FlexGrid啊?
- 各位大哥行行好。
- DataGrid如何行选中
- 怎样写一个程序给当前的屏幕一个COPY,相当于按下Print Screen SysRq键,并把屏幕的COPY保存起来.
- Httphandler ~~~~~~~~~~~~~~求救 高手!
- 关于显示转换的问题?
Always call Dispose before you release your last reference to the Image. Otherwise, the resources it is using will not be freed until the garbage collector calls the Image object's Finalize method.
我这边执行没问题 检查一下后续的代码