M
Mike Johnson
I have the following code in form1 and when the application starts this sub
is called to check for a path if not found a message box is displayed and
then gives the user an option to end the application but when this option is
selected the application does not end but continues to the next line of code
which tries to setup a filewatcher with the path which does not exist, which
then gives an error. please help.
Public Sub Check_For_Dir()
Dim MyPath, MyName As String
Dim Count As Integer
Dim Result As DialogResult
Count = 0
MyPath = FilePath ' Set the path.
MyName = Dir(MyPath, FileAttribute.Directory) ' Retrieve the first entry.
Do While Count <> 10000
If MyName = "" Then ' Start the loop.
Count = Count + 1
MyName = Dir(MyPath, FileAttribute.Directory) 'Check again
Else
Exit Do
End If
Loop
If Count = 10000 Then
'Displays Message
Result = MessageBox.Show("Path " + FilePath + " not available, press Yes to
try again or No to Exit.", "Error", MessageBoxButtons.YesNo)
If Result = DialogResult.Yes Then
'Run Sub again
Check_For_Dir()
Else
'Hide the tray icon.
'NotifyIcon.Visible = False
'Close up.
Me.Close()
Application.Exit()
End If
End If
End Sub
is called to check for a path if not found a message box is displayed and
then gives the user an option to end the application but when this option is
selected the application does not end but continues to the next line of code
which tries to setup a filewatcher with the path which does not exist, which
then gives an error. please help.
Public Sub Check_For_Dir()
Dim MyPath, MyName As String
Dim Count As Integer
Dim Result As DialogResult
Count = 0
MyPath = FilePath ' Set the path.
MyName = Dir(MyPath, FileAttribute.Directory) ' Retrieve the first entry.
Do While Count <> 10000
If MyName = "" Then ' Start the loop.
Count = Count + 1
MyName = Dir(MyPath, FileAttribute.Directory) 'Check again
Else
Exit Do
End If
Loop
If Count = 10000 Then
'Displays Message
Result = MessageBox.Show("Path " + FilePath + " not available, press Yes to
try again or No to Exit.", "Error", MessageBoxButtons.YesNo)
If Result = DialogResult.Yes Then
'Run Sub again
Check_For_Dir()
Else
'Hide the tray icon.
'NotifyIcon.Visible = False
'Close up.
Me.Close()
Application.Exit()
End If
End If
End Sub