Commondialog myStream





'Imports System.IO


'Dim myStream As Stream = Nothing

Dim openFileDialog1 As New OpenFileDialog()

openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "Mdb files (*.Mdb)|*.Mdb"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True

If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Try
myStream = openFileDialog1.OpenFile()
If (myStream IsNot Nothing) Then
' Insert code to read the stream here.

End If
Catch Ex As Exception
MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
Finally
' Check this again, since we need to make sure we didn't throw an exception on open.

If (myStream IsNot Nothing) Then
myStream.Close()
End If
End Try
End If






Dim openFileDialog1 As New OpenFileDialog()

openFileDialog1.InitialDirectory = My.Application.Info.DirectoryPath
openFileDialog1.Filter = "Mdb files (*.Mdb)|*.Mdb"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True

If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Try

PathDataBase = openFileDialog1.FileName
NomeDatabase = openFileDialog1.SafeFileName

Catch Ex As Exception
MessageBox.Show("Errore nell'apertura del database: " & Ex.Message)
Finally
' Check this again, since we need to make sure we didn't throw an exception on open.


End Try
End If










( commondialogmystream.html )- by Paolo Puglisi - Modifica del 17/12/2023