*.csv 导入listView控件出现乱码问题 ????
我的 Csv文件中汉字是 UTF-8格式的。
csv文件我是不能修改的.
当我导入 listview控件上,汉字都显示乱码。。
这是我导入的代码,
Public Function ReadCsv(ByVal fileName As String) As DataSet Dim odbcCSVDataAdapter As OdbcDataAdapter Dim objConn As OdbcConnection Dim filePath As String Dim strConn As String Dim strSql As String Dim TempName As String Dim dsCSV As DataSet filePath = Path.GetDirectoryName(fileName) fileName = Path.GetFileName(fileName) TempName = Split(fileName, ".")(0) strConn = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & filePath & ";Extensions=asc,csv,tab,txt;" objConn = New OdbcConnection(strConn) dsCSV = New DataSet() strSql = "select * from " & fileName odbcCSVDataAdapter = New OdbcDataAdapter(strSql, objConn) Dim mytable As New DataTable(TempName) dsCSV.Tables.Add(mytable) odbcCSVDataAdapter.Fill(dsCSV, TempName) Return dsCSV objConn.Close() End Function Dim csvDataset As New DataSetcsvDataset = ReadCsv(fileName)For i = 0 To csvDataset.Tables(0).Rows().Count() - 1 listview1.Items.Add(New ListViewItem(New String() _ {(csvDataset.Tables(0).Columns(i).ToString) & " :", _ csvDataset.Tables(0).Rows(0).Item(i).ToString}))Next