0

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
2
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by molze
0

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)
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.