用Image.FromFile加载图片会锁文件: Image image = Image.FromFile(fileName);
解决办法:
private Image GetImage( string fileName)
{
byte[] bytes = File.ReadAllBytes(fileName);
using (MemoryStream ms = new MemoryStream(bytes))
{
return Image.FromStream(ms);
}
}
解决办法:
private Image GetImage( string fileName)
{
byte[] bytes = File.ReadAllBytes(fileName);
using (MemoryStream ms = new MemoryStream(bytes))
{
return Image.FromStream(ms);
}
}