|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
File is busyit 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 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 > 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 >> > > 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. -- Show quoteHide quoteDennis in Houston "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 > >> > > > > > > >
Automatic type casting?
Reference To Controls On A Form Visual Basic 2005 CreateFile Crash in VB.NET 2005 Read mail from exchange 2003 DateDiff(DateInterval.DayOfYear Insert related tables into database. Automated Refactoring w/ CodeDom and VBCodeProvider... Problems with FileAccess and PcitoreBox Outlook Add-In: msoControlEdit: Textbox loses text when losing focus |
|||||||||||||||||||||||