944,179 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 3220
  • VB.NET RSS
Mar 23rd, 2007
0

Move actual file DOMDocument()

Expand Post »
I am upgrading a vb 6.0 app to .net and I'm having trouble moving a file. The app retrieves info from an XML. When it's done I try to move the .xml file to a history folder and I'm getting an error:
An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll
Additional information: The process cannot access the file because it is being used by another process.
How do I release the file?
Here's my code

VB.NET Syntax (Toggle Plain Text)
  1. Dim root As MSXML2.IXMLDOMElement
  2. Dim objXMLdoc As New MSXML2.DOMDocument30()
  3. objXMLdoc.Load(Filename)
  4. objXMLdoc.async = False
  5. root = objXMLdoc.documentElement.firstChild.firstChild
  6. GetXMLData() 'USES XPATH... TO RETRIEVE DATA
  7. OutPutRecord() 'outputs retrieved data to an SQL Database
  8. MoveFile(Filename)
  9. Public Function MoveFile(ByVal strfile As String) As Boolean
  10. Dim objfile As New FileInfo(strfile)
  11. 'Try
  12. objfile.MoveTo(Filename)
  13. 'Return True
  14. 'Catch
  15. ' Return False
  16. ' End Try
  17. End Function
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
molze is offline Offline
5 posts
since Mar 2007
Mar 24th, 2007
0

Re: Move actual file DOMDocument()

You are still referencing the file thru the objXMLdoc. Try this
            objXMLdoc.Load(Filename)
            objXMLdoc.async = False
            root = objXMLdoc.documentElement.firstChild.firstChild
            GetXMLData() 'USES XPATH... TO RETRIEVE DATA
            OutPutRecord() 'outputs retrieved data to an SQL Database
            objXMLdoc = Nothing
            MoveFile(Filename)
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
Mar 25th, 2007
0

Re: Move actual file DOMDocument()

It turns out I did not show enough of my code in the first post. The process was actually croaking in another section altogether. There is another spot that I create an XML using FSO. I converted it to StreamWriter and I'm up and rolling! Well I'm ready to tackle the next challenge in the app!

Thanks Wayne
Reputation Points: 10
Solved Threads: 1
Newbie Poster
molze is offline Offline
5 posts
since Mar 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: VisualFox Pro ClassLibrary
Next Thread in VB.NET Forum Timeline: datetimepicker





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC