Move actual file DOMDocument()

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2007
Posts: 5
Reputation: molze is an unknown quantity at this point 
Solved Threads: 1
molze molze is offline Offline
Newbie Poster

Move actual file DOMDocument()

 
0
  #1
Mar 23rd, 2007
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

  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
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: Move actual file DOMDocument()

 
0
  #2
Mar 24th, 2007
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)
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 5
Reputation: molze is an unknown quantity at this point 
Solved Threads: 1
molze molze is offline Offline
Newbie Poster

Re: Move actual file DOMDocument()

 
0
  #3
Mar 25th, 2007
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum


Views: 2468 | Replies: 2
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC