このコードを使用します。わたしにはできる。
私はそのような問題を抱えていて、この記事を見つけました
" http://www.experts-exchange.com/Programming/Languages/.NET/Q_27155602.html "
例はC#でした。手動で vb.net に変換し、「utf8」への変換を追加しました。
Imports System.Text
Public Class Form1
Dim OutputStream As System.IO.StreamWriter
Sub OnDataReceived1(ByVal Sender As Object, ByVal e As System.Diagnostics.DataReceivedEventArgs)
If e.Data IsNot Nothing Then
Dim text As String = e.Data
Dim bytes As Byte() = Encoding.Default.GetBytes(text)
text = Encoding.UTF8.GetString(bytes)
OutputStream.WriteLine(text)
End If
End Sub
Sub CreateBackup()
Dim mysqldumpPath As String = "d:\mysqldump.exe"
Dim host As String = "localhost"
Dim user As String = "root"
Dim pswd As String = "Yourpwd"
Dim dbnm As String = "BaseName"
Dim cmd As String = String.Format("-h{0} -u{1} -p{2} {3}", host, user, pswd, dbnm)
Dim filePath As String = "d:\backup\fieName.sql"
OutputStream = New System.IO.StreamWriter(filePath, False, System.Text.Encoding.UTF8)
Dim startInfo As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo()
startInfo.FileName = mysqldumpPath
startInfo.Arguments = cmd
startInfo.RedirectStandardError = True
startInfo.RedirectStandardInput = False
startInfo.RedirectStandardOutput = True
startInfo.UseShellExecute = False
startInfo.CreateNoWindow = True
startInfo.ErrorDialog = False
Dim proc As System.Diagnostics.Process = New System.Diagnostics.Process()
proc.StartInfo = startInfo
AddHandler proc.OutputDataReceived, AddressOf OnDataReceived1
proc.Start()
proc.BeginOutputReadLine()
proc.WaitForExit()
OutputStream.Flush()
OutputStream.Close()
proc.Close()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CreateBackup()
End Sub
End Class