圖片先讀入MemoryStream 再刪除 (VB.NET)

圖片先讀入MemoryStream 再刪除 (VB.NET)

Imports System.IO
Imports System.Drawing

        Dim myFile As Boolean = IO.File.Exists("c:\webpic.bmp")
        If myFile Then
            Dim Bmp1 As Bitmap
            ' Dim g As Graphics
            Dim ms As New IO.MemoryStream
            Dim b() As Byte
            '將檔案讀入緩衝
            b = FileIO.FileSystem.ReadAllBytes("c:\webpic.bmp")
            '將緩衝寫入記憶體資料流, 並讀取圖片與釋放記憶體資料流
            ms.Write(b, 0, b.Length)
            Bmp1 = New Bitmap(ms)
            IO.File.Delete("c:\webpic.bmp")

            ms.Close()
            ms.Dispose()
 
            PictureBox1.Image = Bmp1
        End If


如有錯誤 歡迎指正