Solved

Add to xml file that is stored in resource.

Posted on 2011-09-30
4
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 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