在WPF VB.NET上命令cmd [英] Command cmd on WPF VB.NET
问题描述
我的代码有问题所以我想在WPF VB.net上使用命令cmd(shell)复制文件,但没有任何反应,所以这就是代码:
我尝试过:
私有子执行者(发件人为对象,e为RoutedEventArgs)处理button1。点击
Dim myProcess As New Process()
myProcess.StartInfo.FileName =cmd.exe'l'application
myProcess.StartInfo .Arguments =/ c copy C:\ Users\FC\Desktop\t.txt C:\ Users\FC\Desktop\\\
n\\\
v
$ b $b'lesparamètrespassésàl'application
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.Start()'lance le process
myProcess.WaitForExit()'参加qu'ilsoitendéavantd'aller plus loin
myProcess。关() 'ferme le process
End Sub
Hi, i have a problem in my code so i want to copy a file using a command cmd (shell) on WPF VB.net but nothing happen ,so this is the code :
What I have tried:
Private Sub executer(sender As Object, e As RoutedEventArgs) Handles button1.Click
Dim myProcess As New Process()
myProcess.StartInfo.FileName = "cmd.exe" 'l'application
myProcess.StartInfo.Arguments = "/c copy C:\Users\FC\Desktop\t.txt C:\Users\FC\Desktop\nn\nv"
'les paramètres passés à l'application
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.Start() 'lance le process
myProcess.WaitForExit() 'attend qu'il soit terminé avant d'aller plus loin
myProcess.Close() 'ferme le process
End Sub
推荐答案
为什么不呢使用 File.Copy方法(字符串,字符串,布尔值)(System.IO) ) [ ^ ]?
因为当出现问题时你会得到例外,并且知道可能是什么来源。使用您的方法,您无法获得这些,当使用shell命令File.Copy
方法失败时也会失败。
Why not just use the File.Copy Method (String, String, Boolean) (System.IO)[^]?
With that you are getting exceptions when something went wrong and do know then what might be the source. With your approach you are not getting these and when theFile.Copy
method fails using the shell command will fail too.
这篇关于在WPF VB.NET上命令cmd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!