Saddle Posted June 16, 2006 Posted June 16, 2006 I have some code that looks for a file in a directory regularly using wildcards because the name changes but the extension doesn't. My code just wants to know the file's name if it is present, not it's contents. My question is "Do I have to use FileClose() between directory searches?" Would I run into problems using the following code: DO $TimeOut = 1000 IF ($Count < 1) then $search = FILEFINDFIRSTFILE("*." & $RoomName) IF ($Search <> -1) THEN $File = FILEFINDNEXTFILE($Search) ..... Do something with the filename found $Count = 10 ENDIF $Count = $Count - 1 ENDIF Sleep($TimeOut) UNTIL ($Finish = $True) Does the filefindfirstfind/filefindnextfile combination actually open the file? Will it fail with some share problem if there are 30 machines looking at the same file? Can the handle $search be reused immediately without a fileclose? Thanks, Saddle (In the land of Oz)
seandisanti Posted June 16, 2006 Posted June 16, 2006 I have some code that looks for a file in a directory regularly using wildcards because the name changes but the extension doesn't. My code just wants to know the file's name if it is present, not it's contents.My question is "Do I have to use FileClose() between directory searches?" Would I run into problems using the following code:DO $TimeOut = 1000 IF ($Count < 1) then $search = FILEFINDFIRSTFILE("*." & $RoomName) IF ($Search <> -1) THEN $File = FILEFINDNEXTFILE($Search) ..... Do something with the filename found $Count = 10 ENDIF $Count = $Count - 1 ENDIF Sleep($TimeOut)UNTIL ($Finish = $True)Does the filefindfirstfind/filefindnextfile combination actually open the file? Will it fail with some share problem if there are 30 machines looking at the same file?Can the handle $search be reused immediately without a fileclose?Thanks,Saddle (In the land of Oz)you don't need to close the search handle for every iteration of your FileFindNextFile loop. you should do a fileclose on $search after the loop though... if your multiple directories you want to search are all in the same tree, you could search all of them with one recursive search... someone (i want to say maybe randallc) has compiled a list of recursive file searches and listers... you may be able to save yourself some time using/modifying one of those...
Saddle Posted June 20, 2006 Author Posted June 20, 2006 Thanks for the reply,The search I need to do is for the same file, I just need to know what the name has changed to, no recursion, no sub-directories. Do I have to close the handle to know if the file has changed name since the last time I looked?you don't need to close the search handle for every iteration of your FileFindNextFile loop. you should do a fileclose on $search after the loop though... if your multiple directories you want to search are all in the same tree, you could search all of them with one recursive search... someone (i want to say maybe randallc) has compiled a list of recursive file searches and listers... you may be able to save yourself some time using/modifying one of those...
seandisanti Posted June 20, 2006 Posted June 20, 2006 Thanks for the reply,The search I need to do is for the same file, I just need to know what the name has changed to, no recursion, no sub-directories. Do I have to close the handle to know if the file has changed name since the last time I looked?i believe so, because you'd have to do that with another filefindfirstfile structure...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now