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