VB 6检查网络上的文件是否存在太长时间 [英] VB 6 Checking if a file on the network exists takes too long
问题描述
以下代码:
如果FileExists(XCustPath +XCust.dat)然后
XCustRun
结束如果
和这段代码:
< pre $ public function FileExists(ByVal Fname As String)As Boolean
Dim lRetVal As Long
Dim OfSt As OFSTRUCT
lRetVal = OpenFile(Fname,OfSt,OF_EXIST)
如果lRetVal<> HFILE_ERROR Then
FileExists = True
Else
FileExists = False
End If
End Function
XCustPath指向映射的网络位置,其中包含文件XCust.dat。
行:
lRetVal = OpenFile(Fname,OfSt,OF_EXIST)
它需要永久的锁定我的程序20-30秒。它需要检查这个文件是否存在于网络上的时间不到1秒,因为这是传统的销售点应用程序。有反正我可以强制它超时的代码行,如果它需要超过一秒?如果它确实存在,它会顺利和完美地运行。或者一个非常快速的方式来检查网络上的文件是否存在?
这应该会更快:
b$ b
Dim fso As Object
设置fso = CreateObject(Scripting.FileSystemObject)
if fso.fileexists(Fname)。 ..
The following code:
If FileExists(XCustPath + "XCust.dat") Then
XCustRun
End If
and this code:
Public Function FileExists(ByVal Fname As String) As Boolean
Dim lRetVal As Long
Dim OfSt As OFSTRUCT
lRetVal = OpenFile(Fname, OfSt, OF_EXIST)
If lRetVal <> HFILE_ERROR Then
FileExists = True
Else
FileExists = False
End If
End Function
XCustPath points to a mapped network location with the file XCust.dat inside it.
But on the line:
lRetVal = OpenFile(Fname, OfSt, OF_EXIST)
It takes forever and locks up my program for 20-30 seconds. It needs to check if this file exists on the network in less than 1 second as it is for a legacy point of sale application. Is there anyway I can force it to timeout the line of code if it takes longer than a second? If it does exist it runs smoothly and perfect. Or a VERY quick way of checking if a file on the network exists?
This should be faster:
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.fileexists(Fname) ...
这篇关于VB 6检查网络上的文件是否存在太长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!