Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15772

VS 2019 [RESOLVED] stuck trying to delete files - is being used by another process

$
0
0
okay so my problem is that i am reading information from XML's,

and i also have a delete button for some that i want to remove after getting the proper information.
tho i am having an error deleting the file after i got the information from inside, saying 'it is being used by another process':

there is no chance another app is accessing that same file, it must be a problem within my code!

Quote:

System.IO.IOException: 'The process cannot access the file 'FilePath.xml' because it is being used by another process.'

here is the code i am using the read information from XML, while avoiding encoding problems and 'case sensitive' tags.

i have tried putting

Stream.Close
and also
textReader.Close

but that did not solve my problem.


Code:

Public Function RipXML(ByRef x As String, y As String)

        Dim Stream As New IO.StreamReader(x, System.Text.Encoding.UTF8)
        Dim textReader As New Xml.XmlTextReader(Stream)
        Dim lastElementName As String = ""
        While textReader.Read()
            Select Case textReader.NodeType
                Case Xml.XmlNodeType.Element
                    lastElementName = textReader.Name
                Case Xml.XmlNodeType.Text
                    If lastElementName.ToLower = y.ToLower Then
                        y = textReader.Value.Trim
                        Return y
                    End If
            End Select
        End While
End Function

trying to delete/;

Code:

My.Computer.FileSystem.DeleteFile(FilePath)

Viewing all articles
Browse latest Browse all 15772

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>