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

File is busy

P: n/a
vul
I need to copy the file (OutboxLog.txt produced by Fax service) right after
it was updated. I'm using:
System.IO.File.Copy(strSource, strDestination, True) to do that, but if the
source file is busy (was not closed yet after update) the copy process
fails.
I tried to insert a loop:
For lngAttempt = 0 To 100000

Application.DoEvents()

Next
It works, but I don't like this approach. I would prefer something like:
Do While IsBusy = True
IsBusy = (some code which returns the status of the file)
Loop

Unfortunately I do not know what do I have to put on the right in this
expression.
Any idea please

Thank you

Al
Feb 6 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I have used:

Do
Try
file.copy(source,dest)
Exit Do
Catch
End Try
Loop

"vul" <aa*@optonline.net> wrote in message
news:us**************@TK2MSFTNGP10.phx.gbl...
I need to copy the file (OutboxLog.txt produced by Fax service) right after
it was updated. I'm using:
System.IO.File.Copy(strSource, strDestination, True) to do that, but if
the source file is busy (was not closed yet after update) the copy process
fails.
I tried to insert a loop:
For lngAttempt = 0 To 100000

Application.DoEvents()

Next
It works, but I don't like this approach. I would prefer something like:
Do While IsBusy = True
IsBusy = (some code which returns the status of the file)
Loop

Unfortunately I do not know what do I have to put on the right in this
expression.
Any idea please

Thank you

Al

Feb 6 '06 #2

P: n/a
vul
Terry, thanks a lot. I works.
Al

"Terry Olsen" <to******@hotmail.com> wrote in message
news:uQ**************@TK2MSFTNGP10.phx.gbl...
I have used:

Do
Try
file.copy(source,dest)
Exit Do
Catch
End Try
Loop

"vul" <aa*@optonline.net> wrote in message
news:us**************@TK2MSFTNGP10.phx.gbl...
I need to copy the file (OutboxLog.txt produced by Fax service) right
after it was updated. I'm using:
System.IO.File.Copy(strSource, strDestination, True) to do that, but if
the source file is busy (was not closed yet after update) the copy
process fails.
I tried to insert a loop:
For lngAttempt = 0 To 100000

Application.DoEvents()

Next
It works, but I don't like this approach. I would prefer something like:
Do While IsBusy = True
IsBusy = (some code which returns the status of the file)
Loop

Unfortunately I do not know what do I have to put on the right in this
expression.
Any idea please

Thank you

Al


Feb 6 '06 #3

P: n/a
As many times as this question is ask on the newsgroups, you'd think M'soft
would get the message and implement a property or method for FileInfo to get
the file status like busy, opened for readonly, opened for write, etc. by
another applicaiton.
--
Dennis in Houston
"vul" wrote:
Terry, thanks a lot. I works.
Al

"Terry Olsen" <to******@hotmail.com> wrote in message
news:uQ**************@TK2MSFTNGP10.phx.gbl...
I have used:

Do
Try
file.copy(source,dest)
Exit Do
Catch
End Try
Loop

"vul" <aa*@optonline.net> wrote in message
news:us**************@TK2MSFTNGP10.phx.gbl...
I need to copy the file (OutboxLog.txt produced by Fax service) right
after it was updated. I'm using:
System.IO.File.Copy(strSource, strDestination, True) to do that, but if
the source file is busy (was not closed yet after update) the copy
process fails.
I tried to insert a loop:
For lngAttempt = 0 To 100000

Application.DoEvents()

Next
It works, but I don't like this approach. I would prefer something like:
Do While IsBusy = True
IsBusy = (some code which returns the status of the file)
Loop

Unfortunately I do not know what do I have to put on the right in this
expression.
Any idea please

Thank you

Al



Feb 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.