Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

VB File Errors between tasks in Win2000

We are just converting application workstations to Windows 2000 and there seems to be a 'slowness' letting go of files in Win2000 that was not there in Win95.

Example:

VB Program does a shell to another program (3rd party product) and must wait until the other process completes: it does this by looking at the files created. Here is the code where it failed with an error #53 - File Not Found

    Do While Dir(mstrSwBundleFileName) = ""
        DoEvents
    Loop
    '-- Now wait until its size is non-zero
    Do While FileLen(mstrSwBundleFileName) = 0
        DoEvents
    Loop
   
In the above, only the file length command could get an 'error 53 file not found'


WHY is it that a DIR command returns the file name, then the FILELEN says file not found???
0
ruskker
Asked:
ruskker
  • 2
1 Solution
 
alainbrydenCommented:

no, file not found applies to the DIR function, because if it's asking what the directory of mstrSwBundleFileName is, and it finds out that mstrSwBundleFileName doesn't exist, then it can't return the directory so it will fail right there. This code should not be executing if mstrSwBundleFileName doesn't exist.
0
 
ruskkerAuthor Commented:
Not so> The DIR function in VB returns a null string when the file is not found and it is used to test for just that.
By the way, this code has been running fine for 6 years on Win95 and this new behaviour started (inconsistently) on Win2000
0
 
tguezCommented:
Your code looks ok. I think the problem is that windows 2000 has a file write-caching.  So when files are writtin to the disk, the are not actually written right now, not necessarily.  Windows can cached them in memory, and then write then to disk later.

So, it could be that the dir command finds the file because it has started to be written into the directory table, but has not yet be actually written out into the disk. Or it has been partially written out to the disk, and not finished wirrtien completel,

So when you get to the filelen, you are getting an error.  

This is just an a tought.  I don't know if is correct, just a thought.

You can test if this is correct in a simple way.  Use the debug mode of visual basic.  Step throught the code.  When it goes out of the loop of the dir, then wait a few seconds until you are sure all the disk data has been written, look at the led of the harddirve.  Then continue to step through.  If what I say is correct, if you waited like 30 seconds, and then you do not get an error, then what i said is what actually is happenning.

If you still get the error, then what I said is not true.

But this could actually be the problem.  If the above works with you debug it and wait 30 seconds, perhaps you can just code in a certain time delay between the first loop and second loop.

Tomer

P.S.  Keep me posted what happens.

Another way to speed up the process is the above is correct, there is some API, look in the documentation, then causes windows to flush all write cache of all applictions.  You can call this function between the two loops.  The regular flush works for your program only, not for other programs.
0
 
ruskkerAuthor Commented:
Tomer

Thanks - I think you are correct. Unfortunately I need to clear the cache of the other process, BUT, what I did was add some sleep time in between the 'dir' and the 'fillen' and after I closed a file to be used by another process. Since I set this time to 10 seconds I have not had the problem in 2 weeks.

Thanks..
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now