Dim openFileDialog1 As New OpenFileDialog
Dim strFileName As String
openFileDialog1.InitialDirectory = "c:\uploads"
openFileDialog1.Filter = "CSV files (*.csv)|*.csv"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True
If openFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
strFiilename = openFileDialog1.FileName
If strFileName <> "" Then
'file is selected
Dim parser As New FileIO.TextFieldParser(strFiilename)
Else
MsgBox("No File Selected")
End If
End If
i think no need to check for this strFileName
because in your question you have placed
Dim parser As New FileIO.TextFieldParser(openFileDialog1.FileName)
after
If openFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
endif
this will leads your error