Private Sub btnbrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbrowse.Click Dim img As String Dim myStream As Stream = Nothing ' openFileDialog1.InitialDirectory = Application.StartupPath OpenFileDialog1.Filter = "Image Files(*.jpg)|*.jpg|Image Files(*.png)|*.png|Image Files(*.bmp)|*.bmp|Image Files(*.gif)|*.gif" If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Try myStream = OpenFileDialog1.OpenFile() If (myStream IsNot Nothing) Then txtfile.Text = "" img = OpenFileDialog1.FileName txtfile.Text = OpenFileDialog1.FileName End If Catch Ex As Exception MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message) Finally If (myStream IsNot Nothing) Then myStream.Close() End If End Try End If End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)