By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,033 Members | 1,285 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,033 IT Pros & Developers. It's quick & easy.

running application using vb.net

P: n/a
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()
Feb 17 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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()

"Lynn" <Ma*******@yah00.c0m> wrote in message
news:OB**************@TK2MSFTNGP11.phx.gbl...
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()

Feb 17 '06 #2

P: n/a
"Lynn" <Ma*******@yah00.c0m> schrieb:
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()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Feb 17 '06 #3

P: n/a
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?
"Lynn" <Ma*******@yah00.c0m> wrote in message
news:OB**************@TK2MSFTNGP11.phx.gbl...
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()

Feb 17 '06 #4

P: n/a
thanks so much

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uS**************@TK2MSFTNGP12.phx.gbl...
"Lynn" <Ma*******@yah00.c0m> schrieb:
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()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Feb 17 '06 #5

P: n/a
how can i verify that all files and folders are copied successfully from the
source ?

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uS**************@TK2MSFTNGP12.phx.gbl...
"Lynn" <Ma*******@yah00.c0m> schrieb:
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()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Feb 17 '06 #6

P: n/a
is there any way that i can automate the checking instead of running the
command again manually?

"AMDRIT" <am****@hotmail.com> wrote in message
news:u1**************@tk2msftngp13.phx.gbl...
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?
"Lynn" <Ma*******@yah00.c0m> wrote in message
news:OB**************@TK2MSFTNGP11.phx.gbl...
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()


Feb 17 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.