Stop the program until copying has been completed
I have written an application in VB 6.0. The program will look for a specific
file in an input directory every 5 minutes. Whenever the program sees the
input file in the input directory, process the file.
Input directory is stored in the variable strIPdir
Input file is strIPfile
Input File name is “test.txt”
I have the code like this
strFileDir = Dir(strIPdir & "test.txt")
If strFileDir <> "" Then
‘goto the procedure to process the file
Call FileProcess(strIPdir, strFileDir)
End if
The size of the file will be between 100 M.B to 130 M.B. Sometimes the size
is more than 130 MB.
In my program I have a timer and every 5 mts the program scans for the input
file. Everything is working fine but sometimes there is a problem. The file
“test.txt” is copied to the input directory from some other location using
some script(not VB). The people in other dept are doing this. When the counter
for the timer is 0 mts and 0 seconds and if the file is in the input dir,
everything works fine, but sometimes when the counter is as 0 mts and 0 seconds
and at the same time the other script is trying to copy the file to the I/p
dir. The program sees the name “test.txt” and starts to process the file
but the copying has not been completed and causes the error.
All I want to do is to pause the program for a minute or 2 before processing
the file, so that the other script could finish the copying. How do I do
this? Please help.
Thanks,
Sinni.
Re: Stop the program until copying has been completed
The easiest way is to see if the script creating the file can lock it until
it has completed. When you try to open the locked file in VB you will get
an error that you can catch. Then reset the timer or whatever else you would
like to do while waiting. I can't remember the error number or message off
the top of my head. I have used something similar in the past but I used
the Sleep api instead of a timer. Good Luck!
"Sinni" <ts2n@yahoo.com> wrote:
>
>I have written an application in VB 6.0. The program will look for a specific
>file in an input directory every 5 minutes. Whenever the program sees the
>input file in the input directory, process the file.
>
>Input directory is stored in the variable strIPdir
>Input file is strIPfile
>Input File name is “test.txt”
>
>I have the code like this
>
>strFileDir = Dir(strIPdir & "test.txt")
>
>If strFileDir <> "" Then
> ‘goto the procedure to process the file
> Call FileProcess(strIPdir, strFileDir)
>End if
>
>The size of the file will be between 100 M.B to 130 M.B. Sometimes the size
>is more than 130 MB.
>In my program I have a timer and every 5 mts the program scans for the input
>file. Everything is working fine but sometimes there is a problem. The file
>“test.txt” is copied to the input directory from some other location using
>some script(not VB). The people in other dept are doing this. When the counter
>for the timer is 0 mts and 0 seconds and if the file is in the input dir,
>everything works fine, but sometimes when the counter is as 0 mts and 0
seconds
>and at the same time the other script is trying to copy the file to the
I/p
>dir. The program sees the name “test.txt” and starts to process the file
>but the copying has not been completed and causes the error.
>All I want to do is to pause the program for a minute or 2 before processing
>the file, so that the other script could finish the copying. How do I do
>this? Please help.
>Thanks,
>Sinni.
>