除去文本中的汉字
Dim currentRow As String
Dim aResult() As String
Dim i As Integer = 0
Dim sFile As String = "e:\photo\test.csv"
ReDim aResult(0 To 1000)
Const iCount As Integer = 500
Dim sPath As String = "e:\photo\abc.csv"
Using MyRead As New Microsoft.VisualBasic.FileIO.TextFieldParser(sPath, System.Text.Encoding.Default)
MyRead.TextFieldType = FileIO.FieldType.Delimited
While Not MyRead.EndOfData
currentRow = MyRead.ReadLine
System.Windows.Forms.Application.DoEvents() '交出控制权
' iCnt = MyRead
If i > aResult.GetUpperBound(0) Then
ReDim Preserve aResult(0 To (i + iCount))
End If
aResult(i) = Regex.Replace(currentRow, "[\u4e00-\u9fa5]", "")
i = i + 1
End While
ReDim Preserve aResult(0 To i - 1) '重新定义数组大小,这样能够去掉空白记录 要加 Preserve
System.IO.File.WriteAllLines(sFile, aResult)
End Using
MessageBox.Show("done!")

浙公网安备 33010602011771号