Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Add to xml file that is stored in resource.

Posted on 2011-09-30
4
Medium Priority
?
288 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
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…
Suggested Courses

636 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