?
Solved

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

Posted on 2003-03-24
5
Medium Priority
?
228 Views
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
0
Comment
Question by:JamesKillian
[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
5 Comments
 
LVL 1

Expert Comment

by:GERTJAN
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.

Gertjan

Public Const INVALID_HANDLE_VALUE = -1
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 WFD As WIN32_FIND_DATA
   Dim hFile As Long
   
   hFile = FindFirstFile(strPath, WFD)
   FileExists = hFile <> INVALID_HANDLE_VALUE
   
   Call FindClose(hFile)
   
End Function
0
 

Author Comment

by:JamesKillian
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.
0
 
LVL 1

Expert Comment

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

Accepted Solution

by:
Passerby earned 150 total points
ID: 8280100
James,

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

Expert Comment

by:CleanupPing
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.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

801 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