Solved

Add to xml file that is stored in resource.

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

863 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

25 Experts available now in Live!

Get 1:1 Help Now