วันพุธที่ 13 กุมภาพันธ์ พ.ศ. 2551

Load image VB.NET 2005

Imports System

Imports System.IO

Imports System.Text

(Use this code to read the jpg:)

Dim FileDir

FileDir = "C:\File.jpg" 'This is the path of your jpg"

Dim fs As New FileStream(FileDir, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) 'you can read the file IF there isnt another app that has exclusive Read/Write.

Picture.Image = Image.FromStream(fs) 'put the image from fs into the picture box

fs.Close() 'close the FileStream; Very important

(When you want to delete the jpg file from your computer use this code:)

My.Computer.FileSystem.DeleteFile(FileDir, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin, FileIO.UICancelOption.DoNothing)