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

Problem With Application.Exit()

P: n/a
Hi,

I have a problem with my application exit, I create a button that call
another form and close my application:

Private Sub closeApplication()
Dim Status As New Status
status.Show()

Application.Exit()
End Sub

At this new form I will rename the exe of the Main Form but when I
execute the:

System.IO.File.Copy(...)

But they give this error at the catch:

System.IO.IOException: The process cannot access the file "C:\......"
because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.File.InternalCopy(String sourceFileName, String
destFileName, Boolean overwrite)
at System.IO.File.Copy(String sourceFileName, String
destFileName, Boolean overwrite)
at Atualizar.Atualizar.trocarArquivos()

Anyone know how can I fix it? Another form to exit "full" to the
application for example ?

Thanx

Dec 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
marciocamurati wrote:
Hi,

I have a problem with my application exit, I create a button that call
another form and close my application:

Private Sub closeApplication()
Dim Status As New Status
status.Show()

Application.Exit()
End Sub

At this new form I will rename the exe of the Main Form but when I
execute the:

System.IO.File.Copy(...)

But they give this error at the catch:

System.IO.IOException: The process cannot access the file "C:\......"
because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.File.InternalCopy(String sourceFileName, String
destFileName, Boolean overwrite)
at System.IO.File.Copy(String sourceFileName, String
destFileName, Boolean overwrite)
at Atualizar.Atualizar.trocarArquivos()

Anyone know how can I fix it? Another form to exit "full" to the
application for example ?

Thanx


This will not do what you want. Application.exit will cease all
processing in all forms. So your exe will stay locked until your
program exits which means you can not do your copy. The way to do what
you want is to start a new process, close the exe your want to copy and
have the new process process do the copying. Which means you basically
need a seperate program to do your copying.

Chris
Dec 21 '05 #2

P: n/a
Hi again,

I found it at the Google search:

http://www.experts-exchange.com/Prog..._21640044.html

And it resolve my problem killing the process of the application if it
alive.
Thanks;.

Dec 21 '05 #3

P: n/a
Hi,

And how can I close that exe ? I execute anther exe that will make the
copy, in this new exe I will send a command to close the other, how can
I do this ?

Thanx

Dec 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.