Stop the program until copying has been completed


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Stop the program until copying has been completed

Hybrid View

  1. #1
    Sinni Guest

    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.


  2. #2
    JCantrell Guest

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



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center