string fileName = @"C:\1.jpg";
try {
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) {
using (BinaryReader br = new BinaryReader(fs)) {
byte[] bytes = br.ReadBytes((int)fs.Length);
MemoryStream ms = new MemoryStream(bytes);
}
}
this.BackgroundImage = Image.FromStream(ms);
} catch (Exception ex) {
logger.Warn(ex);
}
try {
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) {
using (BinaryReader br = new BinaryReader(fs)) {
byte[] bytes = br.ReadBytes((int)fs.Length);
MemoryStream ms = new MemoryStream(bytes);
}
}
this.BackgroundImage = Image.FromStream(ms);
} catch (Exception ex) {
logger.Warn(ex);
}