Checking for a file in a loop?

I need code which will (in a loop) "check" for the existence of a specific file on my HD. Whatever I try, my app. hangs.

This is just so that you can see what I'm trying to do (it hangs):

var
   FileIsThere : boolean;
begin
   FileIsThere := False;
   repeat
      if FileExists('c:\test.wav') then FileIsThere := True;
   until FileIsThere = True;
   // Now I can play the file!!!
end;

Also, if it helps, I have the file size before it is put into the directory.


Cheers, Chris.
LVL 1
she3i3iAsked:
Who is Participating?
 
MotazConnect With a Mentor Commented:
Try to use Application.ProcessMessages at the middle of your for loop:

var
   FileIsThere : boolean;
begin
   FileIsThere := False;
   repeat
      if FileExists('c:\test.wav') then FileIsThere := True;
     Application.ProcessMessages;
   until FileIsThere = True;
   // Now I can play the file!!!
end;

Motaz
0
 
she3i3iAuthor Commented:
Of course!

Why didn't I think of that!?! LOL!

Thanks 4 the reminder...

Chris.
0
All Courses

From novice to tech pro — start learning today.