Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Extreme slowdown when accessing files over the network through VB when using an XP machine.

Posted on 2003-03-24
Medium Priority
Last Modified: 2010-05-01
One part of my program checks the status of various files on other machines over a corporate network as a means of tracking progress on on a centralized machine. One of the issues that I never was able to resolve when using a Win98 box was having to manually open a connection to each machine (open a folder on each machine even though the folder share passwords were stored). When trying to access files in shared folders it would just come up as unavailable if I tried doing from within the VB program if I had not yet manually opened the shared folder.

Well now with WinXP it no longer does this, however that issue has now been replaced with a much more annoying one. Where before access was instant, it now takes 20-30 seconds to open a connection to any of the other machines (that is it no longer makes me manually open a folder, but now it basically locks up while it waits for 20+ seconds for the network connection to complete and the files to become accessible).

I realize this may not be the best forum to ask this question, since I also experience the slowdown when trying to open a shared folder outside of VB using an XP machine, but I thought perhaps someone might know a more direct way of checking a file across the network than what I'm using which would bypass this slowdown (or ideally something to reduce the lag). While I would like to read data from text files instantly without delay, it would suffice if I could at least know whether a named file exists in a given shared folder. Oddly this delay also crops up if there isn't constant communication as well. That is if a few minutes pass without accessing the shared folder, I incurr the long delay once again on the next attempt at access.

Public Function FileExist(strPath As String) As Boolean
    'Check whether a file exists/can be accessed
    Dim X As Integer
    X = FreeFile
    On Error Resume Next
    Open strPath For Input As X
    If Err = 0 Then
        FileExist = True
    Else: FileExist = False
    End If
    Close X
End Function
Question by:JamesKillian

Expert Comment

ID: 8198866
Maybe its quicker when you use a window api to check off the file exist. I am not sure about that. You can try the code below.
Please let me now if you've got a question about the code or let me now how this is working for you.


Public Type WIN32_FIND_DATA
   dwFileAttributes As Long
   ftCreationTime As FILETIME
   ftLastAccessTime As FILETIME
   ftLastWriteTime As FILETIME
   nFileSizeHigh As Long
   nFileSizeLow As Long
   dwReserved0 As Long
   dwReserved1 As Long
   cFileName As String * MAX_PATH
   cAlternate As String * 14
End Type

Public Declare Function FindFirstFile Lib "kernel32" _
   Alias "FindFirstFileA" _
  (ByVal lpFileName As String, _
   lpFindFileData As WIN32_FIND_DATA) As Long
Public Declare Function FindClose Lib "kernel32" _
  (ByVal hFindFile As Long) As Long

Public Function FileExists(strPath As String) As Boolean

   Dim hFile As Long
   hFile = FindFirstFile(strPath, WFD)
   FileExists = hFile <> INVALID_HANDLE_VALUE
   Call FindClose(hFile)
End Function

Author Comment

ID: 8205974
Thanks for the reply, it has the same amount of delay though, I made a quick test and it takes the same amount of time either way.

Expert Comment

ID: 8209405
I'am sorry but i don't now what else you can try.

Accepted Solution

Passerby earned 150 total points
ID: 8280100

I've seen delays like this and they were always due to a network issue.

It could be something like a subnet mask mismatch, or NetBEUI taking preference to TCP/IP and not hearing anything. I've even seen the TCP/IP stack being loaded twice and competing. All resulting in a timeout or rerouting which takes a lot of time.

So take a look at your network settings and those of the other machine.

Expert Comment

ID: 8531703
Hi JamesKillian,
This old question (QID 20561323) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

578 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