Home All Groups Group Topic Archive Search About
Author
6 Feb 2006 1:49 PM
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

Author
6 Feb 2006 1:57 PM
Terry Olsen
I have used:

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

Show quoteHide quote
"vul" <a**@optonline.net> wrote in message
news:usnyjQyKGHA.3936@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
>
Author
6 Feb 2006 2:12 PM
vul
Terry, thanks a lot. I works.
Al

Show quoteHide quote
"Terry Olsen" <tolse***@hotmail.com> wrote in message
news:uQ2zDVyKGHA.1508@TK2MSFTNGP10.phx.gbl...
>I have used:
>
> Do
> Try
>  file.copy(source,dest)
>  Exit Do
> Catch
> End Try
> Loop
>
> "vul" <a**@optonline.net> wrote in message
> news:usnyjQyKGHA.3936@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
>>
>
>
Author
7 Feb 2006 1:58 AM
Dennis
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


Show quoteHide quote
"vul" wrote:

> Terry, thanks a lot. I works.
> Al
>
> "Terry Olsen" <tolse***@hotmail.com> wrote in message
> news:uQ2zDVyKGHA.1508@TK2MSFTNGP10.phx.gbl...
> >I have used:
> >
> > Do
> > Try
> >  file.copy(source,dest)
> >  Exit Do
> > Catch
> > End Try
> > Loop
> >
> > "vul" <a**@optonline.net> wrote in message
> > news:usnyjQyKGHA.3936@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
> >>
> >
> >
>
>
>