[vb.net] 텍스트파일(CSV) 파싱 > vb.net

본문 바로가기

vb.net

[기타] [vb.net] 텍스트파일(CSV) 파싱

익명
2019-09-19 20:48 2,974 0

본문

                    Dim fd As OpenFileDialog = New OpenFileDialog()
                    Dim strFileName As String
 
                    fd.Title = "추가할 파일을 선택해주세요."
                    fd.InitialDirectory = Application.StartupPath
                    fd.Filter = "TEXT Files (*.csv;*.txt)|*.csv;*.txt"
                    fd.FilterIndex = 1
                    fd.RestoreDirectory = True
                    Dim T As String
                    If fd.ShowDialog() = DialogResult.OK Then
                        strFileName = fd.FileName
                        Dim R As DataRow
                        Dim afile As FileIO.TextFieldParser = New FileIO.TextFieldParser(strFileName, System.Text.Encoding.Default)
                        Dim CurrentRecord As String() ' this array will hold each line of data
                        afile.TextFieldType = FileIO.FieldType.Delimited
                        afile.Delimiters = New String() {","}
                        afile.HasFieldsEnclosedInQuotes = True
                        Do While Not afile.EndOfData
                            CurrentRecord = afile.ReadFields
                            '// 이곳에 
                        Loop
                        afile.Close()
                        afile.Dispose()
                        DataGridViewAutoSizeColumn(MyDGV)
                    End If
 

댓글목록0

등록된 댓글이 없습니다.
게시판 전체검색