Good-afternoon all,
I am trying to create this code that will allow me to create a new folder in the directory from what I enter into TextBox1.Text, then open a dialog box and select a PDF which will then put the files path into TextBox2 (the same applies for a separate PDF in TextBox3).
An unhandled exception of type 'System.IO.IOException' occurred in Microsoft.VisualBasic.dll
Additional information: Could not complete operation since a directory already exists in this path '\\ANVILSRV\Public\Completed Works Orders\98789'.
-
This is the error that I am getting when trying to complete the operation, it creates the folder and does not move any files.
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim txt As String
txt = TextBox1.Text
If My.Computer.FileSystem.DirectoryExists("\\ANVILSRV\Public\Completed Works Orders\" & txt & "") Then
MsgBox("Could not create the folder " & txt & " because it already exists.")
Else
My.Computer.FileSystem.CreateDirectory("\\ANVILSRV\Public\Completed Works Orders\" & txt & "")
My.Computer.FileSystem.MoveFile(TextBox2.Text, ("\\ANVILSRV\Public\Completed Works Orders\" & txt & ""), True)
My.Computer.FileSystem.MoveFile(TextBox3.Text, ("\\ANVILSRV\Public\Completed Works Orders\" & txt & ""), True)
End If
End Sub
Any advice or help is much appreciated.
Thanks,
Stephen