I am developing MultiThreaded client-server application in VB.net, where multiple client connect to the one server,there are also process in the server side that open the XML file and write some Data. But after 1 hrs i got the following Error:
"File is used by another proccess."
Is there any suggestion from your side,for above issue. Please check my below code for reading XML
Public Function ISRecordExitsinXML(ByVal pFilepath As String, ByVal pClientIP As String, ByVal pMacAddress As String)
Dim xmlDoc As XmlDocument = Nothing
Dim xmlPupilNode As XmlNode = Nothing
Dim xmlAgeNode As XmlNode = Nothing
Try
Dim FileName As String = pFilepath
ISRecordExitsinXML = Nothing
xmlDoc = New XmlDocument
xmlDoc.Load(FileName)
xmlPupilNode = xmlDoc.SelectSingleNode("//RFIDReader[HostIPAddress = '" & pClientIP.Trim & "' and MacAddress = '" & pMacAddress & "' and Status=1] ")
If Not xmlPupilNode Is Nothing Then
xmlAgeNode = xmlPupilNode.SelectSingleNode("RegDateTime")
If Not xmlAgeNode Is Nothing Then
xmlAgeNode.InnerText = DateTime.Now.ToString()
xmlDoc.Save(FileName)
ISRecordExitsinXML = True
End If
Else
ISRecordExitsinXML = False
End If
xmlDoc = Nothing
xmlPupilNode = Nothing
xmlAgeNode = Nothing
Catch ex As Exception
xmlDoc = Nothing
xmlPupilNode = Nothing
xmlAgeNode = Nothing
ISRecordExitsinXML = False
ErrorLog.WriteToErrorLog(ex.Message.ToString(), "HSRV-A9", "ErrorLog.Log")
Finally
xmlDoc = Nothing
xmlPupilNode = Nothing
xmlAgeNode = Nothing
End Try
Return ISRecordExitsinXML
End Function
Thanks in Advance