c# 讀取圖片文件


        /// <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;
        }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM