Sign in to follow this  
Followers 0
Saddle

Finding Files does it open them?

4 posts in this topic

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)

Share this post


Link to post
Share on other sites



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...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

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...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0