CSharp examples for System.Drawing:Image Effect
Opens an image without locking the file, returns the image if loaded and null if failure.
using System.IO;/*from ww w . jav a2 s .c om*/ using System.Drawing; public class Main{ #region Public Methods and Operators /// <summary> /// Opens an image without locking the file, returns the image if loaded and null if failure. /// </summary> /// <param name="path"> /// The path. /// </param> /// <returns> /// Image. /// </returns> /// <remarks> /// SOURCE: http://stackoverflow.com/questions/4803935/free-file-locked-by-new-bitmapfilepath/8701748#8701748 /// </remarks> public static Image FromFile(string path) { byte[] bytes = File.ReadAllBytes(path); var ms = new MemoryStream(bytes); Image img = Image.FromStream(ms); return img; } }