/// <summary> /// 通過FileStream 來打開文件,這樣就可以實現不鎖定Image文件,到時可以讓多用戶同時訪問Image文件 /// </summary> /// <param name="path"></param> /// <returns></returns> public static Bitmap ReadImageFile(string path) { FileStream fs = File.OpenRead(path); //OpenRead int filelength = 0; filelength = (int)fs.Length; //獲得文件長度 Byte[] image = new Byte[filelength]; //建立一個字節數組 fs.Read(image, 0, filelength); //按字節流讀取 System.Drawing.Image result = System.Drawing.Image.FromStream(fs); fs.Close(); Bitmap bit = new Bitmap(result); return bit; }