Private Sub bSub_Clicker()
Dim tempDir As String = dir.Text
Dim lastChar As String
Dim tempFile As String = file.Text
Dim response As MsgBoxResult
Dim checker As String = ""
If System.IO.File.Exists(dir.Text & "\" & file.Text & ".txt") = False Then
lastChar = HWFunctions.getLast(dir.Text)
If lastChar = "\" Then
response = MsgBox("The file " & tempDir & tempFile & ".txt does not exist." _
& vbCrLf & "Would you like it to be created for you?", 4)
End If
If lastChar <> "\" Then
response = MsgBox("The file " & tempDir & "\" & tempFile & ".txt does not exist." _
& vbCrLf & "Would you like it to be created for you?", 4)
End If
If response = MsgBoxResult.Yes Then
If System.IO.Directory.Exists(dir.Text) = False Then
Try
System.IO.Directory.CreateDirectory(dir.Text)
Catch ex As ArgumentException
MsgBox("Please input a directory name.")
checker = "something"
End Try
End If
If checker = "" Then
lastChar = HWFunctions.getLast(dir.Text)
Try
If lastChar = "\" Then
System.IO.File.Create(tempDir & tempFile & ".txt")
ElseIf lastChar <> "\" Then
System.IO.File.Create(tempDir & "\" & tempFile & ".txt")
End If
Catch ex As UnauthorizedAccessException
MsgBox("Access to the current directory is denied.")
checker = "something"
End Try
My.Settings.chosenDir = dir.Text
My.Settings.chosenFileName = file.Text
End If
End If
If response = MsgBoxResult.No Then
MsgBox("Please choose another directory.")
checker = "something"
End If
Else
My.Settings.chosenDir = dir.Text
My.Settings.chosenFileName = file.Text
If hw.Visible = False Then
hw.Show()
End If
Me.Hide()
End If
If checker = "" Then
If hw.Visible = False Then
hw.Show()
End If
Me.Hide()
End If
End Sub