Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
StrToFile Error Handling?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00642867
Message ID:
00642928
Views:
16
In this case you can use a local error handler
lcOnError = ON("ERROR")
DECALRE Sleep IN Win32API integer
llError = .T.

DO WHILE llError
  llError = .F.
  ON ERROR llError = .T.
  ERASE (lcFileName)
  ON ERROR &lcOnError 
  IF NOT llError 
     EXIT
  ENDIF
  Sleep(1000)
ENDDO
Or you can wrap you code in a class and use class error() method to handle ERASE errors.

>My problem is that another process/thread could start to use the file in the milliseconds between the time I see that the file is not in use and when I try to erase it. That's why I'd rather try to erase it until I actually do.
>
>
>>You can use FOPEN() function to check if file is open somewhere else.
lnFH = FOPEN(lcFileName, 12)
>>IF lnFH > 0    && file isn't in use
>>  FCLOSE(lnFH)
>>  .....
>>ELSE
>>ENDIF
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform