Convert an XML file into a Binary Format File

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 39
Reputation: btech_Saurabh is an unknown quantity at this point 
Solved Threads: 2
btech_Saurabh's Avatar
btech_Saurabh btech_Saurabh is offline Offline
Light Poster

Convert an XML file into a Binary Format File

 
0
  #1
Jan 4th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Convert an XML file into a Binary Format File

 
0
  #2
Jan 4th, 2008
Just read your XML file as normal file,
  1. string xmlData = File.ReadAllText("path.xml");
then write this data to your binary file
  1. FileStream fs = new FileStream("path.txt", FileMode.OpenOrCreate);
  2. BinaryWriter sw = new BinaryWriter(fs);
  3. sw.Write(s);
  4. sw.Close();
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 39
Reputation: btech_Saurabh is an unknown quantity at this point 
Solved Threads: 2
btech_Saurabh's Avatar
btech_Saurabh btech_Saurabh is offline Offline
Light Poster

Re: Convert an XML file into a Binary Format File

 
0
  #3
Jan 4th, 2008
Originally Posted by RamyMahrous View Post
Just read your XML file as normal file,
  1. string xmlData = File.ReadAllText("path.xml");
then write this data to your binary file
  1. FileStream fs = new FileStream("path.txt", FileMode.OpenOrCreate);
  2. BinaryWriter sw = new BinaryWriter(fs);
  3. sw.Write(s);
  4. sw.Close();

No, Its Not Working......it shows the same data........in XML format
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Convert an XML file into a Binary Format File

 
0
  #4
Jan 4th, 2008
Encrypt your data!!!
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 39
Reputation: btech_Saurabh is an unknown quantity at this point 
Solved Threads: 2
btech_Saurabh's Avatar
btech_Saurabh btech_Saurabh is offline Offline
Light Poster

Re: Convert an XML file into a Binary Format File

 
0
  #5
Jan 4th, 2008
Thanx for the Nice Advice......but i have done it .....by using........BinaryFormatter.....
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Convert an XML file into a Binary Format File

 
0
  #6
Jan 4th, 2008
System.Security.Cryptography may help you for stronger and better encryption!
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 39
Reputation: btech_Saurabh is an unknown quantity at this point 
Solved Threads: 2
btech_Saurabh's Avatar
btech_Saurabh btech_Saurabh is offline Offline
Light Poster

Re: Convert an XML file into a Binary Format File

 
0
  #7
Jan 4th, 2008
Thanx......Man
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC