C#读取图像文件的不锁定文件代码
/// <summary> /// 读取图片文件 /// </summary> /// <param name="path">图片文件路径</param> /// <returns>图片文件</returns> private Bitmap ReadImageFile(string path) { Bitmap bitmap = null; try { using (var fileStream = File.OpenRead(path)) { var filelength = (int)fileStream.Length; var image = new byte[filelength]; fileStream.Read(image, 0, filelength); var result = Image.FromStream(fileStream); bitmap = new Bitmap(result); } } catch (Exception ex) { // 异常输出 Console.WriteLine(ex.Message); } return bitmap; }