在VB 2010项目中使用robocopy.exe [英] Use robocopy.exe in a VB 2010 project

查看:76
本文介绍了在VB 2010项目中使用robocopy.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS 2010中创建了一个新项目,以使用robocopy.exe在我的计算机上将文件从e:复制到f:.

Created a new project in VS 2010 to copy a file from e: to f: on my computer using robocopy.exe.

公共类CopyFile
   私有子Button1_Click(ByVal发送者为System.Object,ByVal e为System.EventArgs)处理Button1.Click
       Process.Start(My.Computer.FileSystem.CurrentDirectory&" \ robocopy.exe"""" e:\"& quot;"""" f:\" &"&" hb.mkv")
   结束子
结束班

Public Class CopyFile
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Process.Start(My.Computer.FileSystem.CurrentDirectory & "\robocopy.exe" & " " & "e:\" & " " & "f:\" & " " & "hb.mkv")
    End Sub
End Class

当我单击按钮时,出现找不到文件的错误.

When i click on button, i get file not found error.

-我将robocopy.exe添加到了项目中,并将复制到输出目录"设置为始终复制".

- i added robocopy.exe to the project and 'Copy to output directory' is set to 'Copy always'.

请帮助我.

推荐答案

我会先将命令分配给变量,以便您可以对其进行检查.我假设异常/错误来自.NET代码而不是robocopy?

I would assign your command to a variable first so you can examine it. I'm assuming the exception/error is coming from the .NET code and not robocopy?

CurrentDirectory将评估应用程序集的位置,该位置将是调试"或发布"文件夹.

CurrentDirectory will evaluate to the location of the application assembly if you are running from the IDE, which will be the Debug or Release folder.


这篇关于在VB 2010项目中使用robocopy.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆