running application using vb.net

L

Lynn

Hi,
I use the following code to run xcopy, but my application hangs after the
copying has finished. What could be wrong?

Dim psi As New ProcessStartInfo()
psi.FileName = "xcopy"
psi.Arguments = "c:\abc d:\abc"
Process.Start(psi)
Process.GetCurrentProcess.WaitForExit()
 
T

Terry Olsen

This line: Process.GetCurrentProcess.WaitForExit() is waiting for your
application to end, not the process. So that causes the app to hang.
Assuming you have a reason for not using the built-in File.Copy() function,
try this code.

Dim MyProcess as New Process
Dim psi as New ProcessStartInfo()
psi.FileName="xcopy"
psi.Arguments="c:\abc d:\abc"
MyProcess.ProcessStartInfo=psi
MyProcess.Start()
MyProcess.WaitForExit()
 
H

Herfried K. Wagner [MVP]

Lynn said:
I use the following code to run xcopy, but my application hangs after the
copying has finished. What could be wrong?

Dim psi As New ProcessStartInfo()
psi.FileName = "xcopy"
psi.Arguments = "c:\abc d:\abc"
Process.Start(psi)
Process.GetCurrentProcess.WaitForExit()

\\\
Dim p As Process = Process.Start("xcopy", "C:\abc D:\abc")
p.WaitForExit()
///
 
A

AMDRIT

Run the command in the commandwindow. I wonder if you are being prompted to
overwrite a file.

You realize that with a few more lines of code, you can replicate your own
xcopy routine using system.io namespace?
 
L

Lynn

is there any way that i can automate the checking instead of running the
command again manually?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top