954,198 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Move actual file DOMDocument()

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

Dim root As MSXML2.IXMLDOMElement
    Dim objXMLdoc As New MSXML2.DOMDocument30()
            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
            MoveFile(Filename)
    Public Function MoveFile(ByVal strfile As String) As Boolean
        Dim objfile As New FileInfo(strfile)
        'Try
        objfile.MoveTo(Filename)
        'Return True
        'Catch
        '   Return False
        '  End Try
    End Function
molze
Newbie Poster
5 posts since Mar 2007
Reputation Points: 10
Solved Threads: 1
 

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)
waynespangler
Posting Pro in Training
461 posts since Dec 2002
Reputation Points: 84
Solved Threads: 58
 

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

molze
Newbie Poster
5 posts since Mar 2007
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You