For Each drv In IO.DriveInfo.GetDrives
If drv.IsReady And drv.DriveType = IO.DriveType.Removable Then ???= drv.Name()ชื่อ drive
End If
Next
OpenFile.InitialDirectory ="????"
OpenFile.FileName = ""
OpenFile.Filter = "Text files (*.txt)|*.txt"
Dim Res As System.Windows.Forms.DialogResult = OpenFile.ShowDialog()
If Res = System.Windows.Forms.DialogResult.Cancel Then Return
txtFile.Text = OpenFile.FileName
Tag : .NET, Ms SQL Server 2008, Win (Windows App), VB.NET, VS 2010 (.NET 4.x)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim OpenFile As New OpenFileDialog()
For Each drv In IO.DriveInfo.GetDrives
If drv.IsReady And drv.DriveType = IO.DriveType.Removable Then
OpenFile.InitialDirectory = drv.Name
OpenFile.FileName = ""
OpenFile.Filter = "Text files (*.txt)|*.txt"
Dim Res As System.Windows.Forms.DialogResult = OpenFile.ShowDialog()
If Res = System.Windows.Forms.DialogResult.Cancel Then Return
txtFile.Text = OpenFile.FileName
End If
Next
End Sub