?
Solved

Add to xml file that is stored in resource.

Posted on 2011-09-30
4
Medium Priority
?
290 Views
Last Modified: 2012-05-12
I have an xml file i saved into a resource that i can access via my.resouces.xmlfile

I want to add to that xml file and save it while the program is running so that it is all "embedded" into the exe.

So below is my xml file i have that is saved in my resouce folder as test.xml. I need to know how to write new xml to it as well as delete xml from it if need be.
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
  <Student>
    <StudentName />
    <StudentID />
    <Image />
    <Location />
    <SmartSpeech />
  </Student>
  <Student>
    <StudentName>Corey Gashlin</StudentName>
    <StudentID>5993153492</StudentID>
    <Image>5993153492.jpg</Image>
    <Location>c:\</Location>
    <SmartSpeech>YES</SmartSpeech>
  </Student>
</NewDataSet>

Open in new window

0
Comment
Question by:desiredforsome
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36892438
0
 

Author Comment

by:desiredforsome
ID: 36892491
I have already looked at that.
0
 
LVL 7

Accepted Solution

by:
vbigham earned 2000 total points
ID: 36894646
You want to modify the exe at the same time that it is running?

I don't think that is going to happen.  Even if Windows would let you do that, it probably shouldn't.  If you wanted to modify it from a different program, that should work, but I don't know how to tell you to go about finding the right bytes to modify (maybe you can check into the System.IO.Packaging namespace http://msdn.microsoft.com/en-us/library/system.io.packaging.package.aspx but I might be leading you on a wild goose chase with that one).  

You're best bet is probably to write it to a separate file, and read/write from the new file.  If the concern is whether or not the user can read / modify the file directly, you might want to consider encrypting the contents and/or hiding the file with the FileAttributes.Hidden flag.

The XmlSerializer might be an easy way to go for the reading/writing the xml in an object relational way, though I'm not sure what the performance impact would be compared to the Linq to Xml solution.
http://support.microsoft.com/kb/316730

Here is an example that should help you with encryption.
http://www.codeproject.com/KB/security/EncryptFile.aspx
0
 
LVL 8

Expert Comment

by:cubaman_24
ID: 36902355
Hello:
It's a poor design. You should the functional design to not relay on compiled resources. Put your data as an standalone xml file, or save it to a DDBB if you need to restrict access to it.
You can't modify a program from within it while running.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question