Solved

VB File Errors between tasks in Win2000

Posted on 2006-06-21
4
166 Views
Last Modified: 2010-04-30
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
Comment
Question by:ruskker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 20

Expert Comment

by:alainbryden
ID: 16954054

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
 

Author Comment

by:ruskker
ID: 16956273
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
 
LVL 1

Accepted Solution

by:
tguez earned 500 total points
ID: 17040245
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
 

Author Comment

by:ruskker
ID: 17063341
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month5 days, 16 hours left to enroll

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question