views:

74

answers:

4

How to encrypt WHOLE an xml file using C#?

+2  A: 

If I understand you question, you might start by looking at System.Security.Cryptography namespace in .Net, and in particular at the CryptoStream class.

GregS
A: 

Here's a link you might find useful:

http://stackoverflow.com/questions/202011/encrypt-decrypt-string-in-net

code4life
A: 

I know how to encrypt string. But I dunno how to encrypt an XML file, not only nodes - whole XML file.

Alex Maslakov
FYI the proper way to add more information is to edit your original question instead of posting and answer. That aside though, an XML file is just a file that contains a string of text. The string just happens to be in a certain format, so I don't see how it's different from encrypting any other string. Unless you need help reading text from the file which is a different question.
Davy8
A: 

If you mean how to encrypt the XML file within code and save it back to disk, you can read the XML file as simple text. In that form it is nothing but a long string. Use the method you are familiar with to encrypt it. Then save it back to disk as a standard binary file. Reverse that to decrypt the file.

If you just want to encrypt the file on the drive, in Windows you can do that from the file properties.

Gil