System.IO issue for a newb
Can anyone tell me why I get an error stating that the file is still is still in use and it bombs with an IO exception:
"The process cannot access the file 'C:\Users\Ken\Dropbox\Test Files\Select A Category\Select A Sub-Category\textbox1.text & " " & textbox2.text.xml' because it is being used by another process. Below is my code:
If System.IO.Directory.Exists(TextBox57.Text & "\Select A Category\Select A Sub-Category\") = False Then
System.IO.Directory.CreateDirectory(TextBox57.Text & "\Select A Category\Select A Sub-Category\")
End If
'System.IO.File.Create(TextBox57.Text & "\Select A Category\Select A Sub-Category\" & TextBox1.Text & " " & TextBox2.Text & ".xml")
Dim Writer3 As XmlTextWriter = New XmlTextWriter(TextBox57.Text & "\" & ComboBox3.Text & "\" & ComboBox6.Text & "\" & TextBox1.Text & " " & TextBox2.Text & ".xml", System.Text.Encoding.UTF8)
If ComboBox3.Text <> "Select A Category" Then
Writer3.WriteStartDocument()
' Create the root element named Resume Entry
Writer3.WriteStartElement("ResumeEntry")
' Start a child element named Client
Writer3.WriteStartElement("Client")
' Create a number for the First Name
Writer3.WriteStartElement("FirstName")
Writer3.WriteString(TextBox1.Text)
Writer3.WriteEndElement()
' Create a name for the Last Name
Writer3.WriteStartElement("LastName")
Writer3.WriteString(TextBox2.Text)
Writer3.WriteEndElement()
' Close the student node
Writer1.WriteEndElement()
' Close the root element
Writer1.WriteEndElement()
Writer1.WriteEndDocument()
Writer1.Flush()
Writer1.Close()
End If
|
Last edited by SwsCheez; 07-14-2014 at 05:23 PM.
Reason: Used wrong file in error
|