954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Convert an XML file into a Binary Format File

Hi Developers.....

I have a Problem.... I have a XML file.....n I have to Read the Data from that XML file n Create a New File and the Data is in a Binary Format.....(All the code is in C# only)

I have used the BinaryReader,BinaryWriter and BinaryFormatter but i can't able to solve this problem.....if i use the array of byte then the data comes in array is in ASCII code and then i convert each n every word into binary is a very very huge process.......Is there any Function in C#.Net by which i can convert my XML file to a Binary Format File.....

Every Comment will be Welcome.....
Thanx

btech_Saurabh
Light Poster
39 posts since Jan 2008
Reputation Points: 10
Solved Threads: 2
 

Just read your XML file as normal file,

string xmlData = File.ReadAllText("path.xml");


then write this data to your binary file

FileStream fs = new FileStream("path.txt", FileMode.OpenOrCreate);
BinaryWriter sw = new BinaryWriter(fs);
sw.Write(s);
sw.Close();
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

Just read your XML file as normal file,

string xmlData = File.ReadAllText("path.xml");

then write this data to your binary file

FileStream fs = new FileStream("path.txt", FileMode.OpenOrCreate);
BinaryWriter sw = new BinaryWriter(fs);
sw.Write(s);
sw.Close();


No, Its Not Working......it shows the same data........in XML format

btech_Saurabh
Light Poster
39 posts since Jan 2008
Reputation Points: 10
Solved Threads: 2
 

Encrypt your data!!!

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

Thanx for the Nice Advice......but i have done it .....by using........BinaryFormatter.....

btech_Saurabh
Light Poster
39 posts since Jan 2008
Reputation Points: 10
Solved Threads: 2
 

System.Security.Cryptography may help you for stronger and better encryption!

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

Thanx......Man

btech_Saurabh
Light Poster
39 posts since Jan 2008
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You