Visual Basic.NET
--
Questions
--
Followers
Top Experts
Problem is that there doesn't seem to be an easy way to determine if the path DOESN'T exist, so no processing time is wasted.
So my question is two fold -
First, is there a call I can make thatwill instantly determine if a path exists (without timing out)
and Second
If I add a Cancel button to the process which sets a cancel flag, how can I trap the flag?
(I tried putting in Application.DoEvents, but when its stuck on a directory that doesn't exist, it never catches the flag. I also tried using the Directory object and it too has a long time out..)
If fi.Exists = True Then
lvFound.Items.Add(fi.FullN
End If
Application.DoEvents()
If bCancel = True Then
bCancel = False
MsgBox("Search Canceled", MsgBoxStyle.Exclamation, "Locate Files")
butCancel.Enabled = False
ssStatus.Text = ""
Cursor.Current = Cursors.Default
Exit Sub
End If
???
Thanks
Carp
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
If My.Computer.FileSystem.Fil
'Process...
End If
If the directory doesn't exist there's no way to interupt the process until the timeout.
Thanks for the response though.
Example:
"Q" is a mapped drive that does NOT have the subdirectory \MyFiles\MyImages\:
.FileExists (Q:\MyFIles\MyImages\afile
'Obviously "somefakepath" isn't a valid path.
If My.Computer.FileSystem.Fil
'Process...
End If
And it doesn't matter what the path is. I can enter a path with a fake drive letter, but same thing: immediate return.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Dim fso As Object
Set fso = CreateObject("Scripting.Fi
If fso.FileExists(fi.FullName
MsgBox "Exists"
Else
MsgBox "Does not exist"
End If
I should re-phrase the question -
Is there a way to check the connected drive list to see if the connection is actually valid without waiting for the timeout?
This gets me a list of mapped drives, HOWEVER they may not be all accesible -
dri = DriveInfo.GetDrives
For my particular issue, one of the drives in the array generates a "An Error Occured While reconnecting ..." message even when clicked form Explorer, thus the excessive time out.
So the REAL question is if there is a way to quickly determine if a dirve is valid.
I think the answer is no...
(Thanks again for taking a look and I apologize for incorrectly stating the issue...)
Carp
For Each dri As IO.DriveInfo In IO.DriveInfo.GetDrives()
If dri.IsReady = True Then
MsgBox(dri.Name & " is ready")
End If
Next

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Carp
Visual Basic.NET
--
Questions
--
Followers
Top Experts
Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,