July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.
Dim fName As String = "" OpenFileDialog1.InitialDirectory = "c:\temp\" OpenFileDialog1.Filter = "CSV files (*.csv)|*.CSV" OpenFileDialog1.FilterIndex = 2 OpenFileDialog1.RestoreDirectory = True If (OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) Then fName = OpenFileDialog1.FileName End If Dim TextLine As String = "" Dim SplitLine() As String If System.IO.File.Exists(fName) = True Then Dim objReader As New System.IO.StreamReader(fName) Do While objReader.Peek() <> -1 TextLine = objReader.ReadLine() SplitLine = Split(TextLine, ",") Me.DataGridView1.Rows.Add(SplitLine) Loop Else MsgBox("File Does Not Exist") End If
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.