最后使用CMD曲线救国,老师帮助看下这段代码有没有问题?我本机运行良好,我怕那些老电脑有问题(不能使用FileSys.CopyFile,一样会报错)Dim fi As String = e.FileName
Dim fi1 As String = e.SubFolder
Dim fi2 As String = e.DataCol.DefaultFolder
Dim aa As String
If ftppp = False Then
If FileSys.FileExists(fi2 & "\" & fi1 & "\" & fi) Then
aa = Rand.NextString(4) & fi
Else
aa = fi
End if
Dim p As New Process()
p.StartInfo.FileName = "cmd.exe"
p.StartInfo.UseShellExecute = False '关闭Shell的使用
p.StartInfo.RedirectStandardInput = True '重定向标准输入
p.StartInfo.RedirectStandardOutput = True '重定向标准输出
p.StartInfo.RedirectStandardError = True '重定向错误输出
p.StartInfo.CreateNoWindow = True '设置不显示窗口
p.Start()
Dim bb As String = "echo f| xcopy """ & e.SourceFolder & "\" & fi & """ """ & fi2 & "\" & fi1 & "\" & aa & """ /i /D /s /e /c /y"
p.StandardInput.WriteLine(bb)
p.StandardInput.WriteLine("exit")
If e.DataRow(e.DataCol.Name) = Nothing Then
e.DataRow(e.DataCol.Name) = fi1 & "\" & aa
Else
e.DataRow(e.DataCol.Name) &= vbCrLf & fi1 & "\" & aa
End If
e.Cancel = True
End If