Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim ds1 As New DataSet
Dim dt1 As New DataTable
Dim ifile As FileInfo = Nothing '创建文件对象
Dim reader As StreamReader = Nothing
Dim ipath As String = "C:\ProgramData\MySQL\MySQL Server 5.7\Data\schema\"
Dim ifileArr() As String = Directory.GetFiles(ipath) '存放文件名的数组
Dim isFinished As Boolean = False '文件读取完成标志
Dim strReader As StreamReader = Nothing
Try
For i = 0 To ifileArr.Length - 1
ifile = New FileInfo(ifileArr(i)) '实例化文件对象
strReader = New StreamReader(ifile.ToString, System.Text.Encoding.Default)
If (Not isFinished) Then
isFinished = F_Readfile(strReader)
' ifile.
' ifile = ifile.SaveFile(testFile, strTest, "gb2312")(这句话永不了啊)
ifile.Delete()
End If
isFinished = False
strReader.Close()
Next
Catch ex As ApplicationException
ex.Message.ToString()
Finally
End Try
MsgBox("全部完成,共写入数据库" & ifileArr.Length & "个文件!")
End Sub
1 个解决方案
#1
文件不大的话
dim strContent as string=system.io.file.readalltext(file,system.text.encoding.utf8)
'dim strContent as string=system.io.file.readalltext(file,system.text.encoding.getencode("gbk")
system.io.file.writealltext(newfile, system.text.encoding.utf8)
#1
文件不大的话
dim strContent as string=system.io.file.readalltext(file,system.text.encoding.utf8)
'dim strContent as string=system.io.file.readalltext(file,system.text.encoding.getencode("gbk")
system.io.file.writealltext(newfile, system.text.encoding.utf8)