System.IO issue for a newb
System.IO issue for a newb
System.IO issue for a newb
System.IO issue for a newb
System.IO issue for a newb
System.IO issue for a newb System.IO issue for a newb System.IO issue for a newb System.IO issue for a newb System.IO issue for a newb System.IO issue for a newb System.IO issue for a newb System.IO issue for a newb
System.IO issue for a newb System.IO issue for a newb
System.IO issue for a newb
Go Back  Xtreme Visual Basic Talk > > > System.IO issue for a newb


Reply
 
Thread Tools Display Modes
  #1  
Old 07-14-2014, 06:19 PM
SwsCheez SwsCheez is offline
Newcomer
 
Join Date: Oct 2012
Posts: 13
Default 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 06:23 PM. Reason: Used wrong file in error
Reply With Quote
  #2  
Old 07-15-2014, 03:26 AM
Cerian Knight's Avatar
Cerian KnightSystem.IO issue for a newb Cerian Knight is online now
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,199
Default

If I had to guess, the literal of 'textbox1.text' showing up in the error file means that you have quotes or similar in the textbox interfering with the concatenation. Try displaying the string within 'Dim... New XmlTextWriter' to be sure.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
System.IO issue for a newb
System.IO issue for a newb
System.IO issue for a newb System.IO issue for a newb
System.IO issue for a newb
System.IO issue for a newb
System.IO issue for a newb System.IO issue for a newb System.IO issue for a newb System.IO issue for a newb System.IO issue for a newb System.IO issue for a newb System.IO issue for a newb
System.IO issue for a newb
System.IO issue for a newb
 
System.IO issue for a newb
System.IO issue for a newb
 
-->