Solved

Add to xml file that is stored in resource.

Posted on 2011-09-30
4
277 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 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now