Can't Save to an XML file in an embedded resource

I am testing an app to read from a XML file (Working) and save to a XML file (NOT WORKING).

Here is my code that is not working. any ideas on how to fix this? I need to be able to save to the XML file. The error I am getting is: STREAM WAS NOT WRITEABLE

Code:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim strTime As String
    strTime = Now.ToString
    Dim _assembly As Assembly
    _assembly = [Assembly].GetExecutingAssembly()
    Dim FileName = _assembly.GetManifestResourceStream("EmbeddedResource.xml")

    Try
        Dim xmlData As New XmlDocument
        Dim nodeRoot, nodeTroubleInfo, nodeDateTimeSaved As XmlNode
        xmlData.Load(FileName)
        nodeRoot = xmlData.SelectSingleNode("//DATA")
        nodeTroubleInfo = nodeRoot.SelectSingleNode("//TroubleInfo")
        nodeTroubleInfo.InnerText = txtNotes.Text
        nodeDateTimeSaved = nodeRoot.SelectSingleNode("//DateTimeSaved")
        nodeDateTimeSaved.InnerText = strTime
        xmlData.Save(FileName)
        MsgBox("SAVE Button Pressed!", MsgBoxStyle.Information, "Note saved successfully!")
    Catch ex As Exception
        MsgBox("Error saving note. The error was: " & vbCrLf & Err.Description, MsgBoxStyle.Exclamation, "Error saving information to file.")
        Exit Sub
    End Try
End Sub

Answers


It's not a file. It's part of the assembly. You cannot write to it.

The best you could do is read from the assembly and write to a separate XML file on disk. That file, you could read and write.


Need Your Help

Update source data or series ollection of a line chart

excel vba excel-vba

I am trying to automate a line chart to include new rows of data in a column (from cell H11) using this VBA command:

fullPage.js not scrolling

javascript jquery fullpage.js

I would like to use fullPage.js in my wp site.