Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7407203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:40:35+00:00 2026-05-29T05:40:35+00:00

Hello I’m getting this error, while trying to save serial number to XML File.

  • 0

Hello I’m getting this error, while trying to save serial number to XML File.
If the file doesn’t exist, it saves the file fine, but if i change Registered tag to False in Xml file, and try again, it says “The Process Cannot acces the file … because it is being used by another process”.
In my main form i read the information from XML, and in my regform (which i open if registered tag in xml is false) i write to the file. is it because of that?! I don’t think so.
Here is my Registration class:

    Imports System.IO
    Imports System.Xml

    Public Class RegistrationClass
    Public Property SerialNumber As String
    Public Property Registered As Boolean = False
    Public Sub Write_Reg(ByVal FileString As String, ByVal RegisterName As String, ByVal          RegisterCompany As String, ByVal RegisterSerialNumber As String)
        Dim Registered As Boolean = False
        Dim Comment As String = "StroySoft 2012 Register Database"
        Dim SerialNumber As String = "dev-xxx-123"
        Dim ClientOS As String = Trim(My.Computer.Info.OSFullName)
        If RegisterSerialNumber = SerialNumber Then
            Dim settings As New XmlWriterSettings()
            settings.Indent = True

            ' Initialize the XmlWriter.
            Dim XmlWrt As XmlWriter = XmlWriter.Create(FileString, settings)

            With XmlWrt

                ' Write the Xml declaration.
                .WriteStartDocument()

                ' Write a comment.
                .WriteComment(Comment)

                ' Write the root element.
                .WriteStartElement("Data")

                ' Start our first person.
                .WriteStartElement("Register")

                ' The person nodes.

                .WriteStartElement("Name")
                .WriteString(RegisterName.ToString())
                .WriteEndElement()

                .WriteStartElement("Company")
                .WriteString(RegisterCompany.ToString())
                .WriteEndElement()

                .WriteStartElement("SerialNumber")
                .WriteString(RegisterSerialNumber.ToString())
                .WriteEndElement()

                Registered = True
                .WriteStartElement("Registered")
                .WriteString(Registered)
                .WriteEndElement()

                .WriteStartElement("ClientOS")
                .WriteString(ClientOS)
                .WriteEndElement()

                ' The end of this person.
                .WriteEndElement()

                ' Close the XmlTextWriter.
                .WriteEndDocument()
                .Close()
            End With
            MsgBox("Успешна регистрация! Благодарим Ви!")
            MainForm.РегистрацияToolStripMenuItem.Visible = False
        Else
        MsgBox("Невалиден сериен номер!")
        End If
    End Sub
    Public Sub Check_Reg(ByVal FileString As String)
        If (System.IO.File.Exists(FileString)) Then

            Dim document As XmlReader = New XmlTextReader(RegForm.RegFile)

            While (document.Read())

                Dim type = document.NodeType

                If (type = XmlNodeType.Element) Then

                    If (document.Name = "Registered") Then
                        If document.ReadInnerXml.ToString() = "True" Then
                            Registered = True
                        Else
                            Registered = False
                        End If

                    End If

                    If (document.Name = "SerialNumber") Then
                        SerialNumber = document.ReadInnerXml.ToString()
                    End If

                End If

            End While

        Else

            MessageBox.Show("The filename you selected was not found.")

        End If
    End Sub
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:40:36+00:00Added an answer on May 29, 2026 at 5:40 am

    is it because of that?! I don’t think so.

    It’s exactly because of that.

    You should always make sure to properly dispose IDisposable resources such as Streams and Writers/Readers by wrapping them in a Using block. In your case I don’t see you closing your reader. But if you wrap it in a Using block you shouldn’t worry about it. Even if an exception is thrown the resource will be properly released.

    Example:

    Using XmlWrt As XmlWriter = XmlWriter.Create(FileString, settings)
        ...
    End Using
    

    You should do the same with your XmlReader:

    Using document As XmlReader = XmlReader.Create(RegForm.RegFile)
        ...    
    End Using
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello Guys I am trying to figure out why i am gettings this error
Hello I wrote an application and while deploying shows error in line mCamera=Camera.open(); Where
Hello everyone i am trying to format the input number range with php number_format
hello im am getting JS error : Uncaught SyntaxError: Unexpected identifier here <script type=text/javascript>
Hello all in my iphone application after sending login xml request am getting following
hello i got a batch file, something like this: if %day%==monday, tuesday, wednesday, thursday,
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello can anybody solve this please I'm creating the object in the action class
Hello I am compiling a program with make but I get the error of
Hello I am working with a simulator that uses rcS scripts to boot, this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.