User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 402,510 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,667 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 2950 | Replies: 6
Reply
Join Date: Jan 2008
Location: Punjab(....India....)
Posts: 31
Reputation: btech_Saurabh is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
btech_Saurabh's Avatar
btech_Saurabh btech_Saurabh is offline Offline
Light Poster

Question Convert an XML file into a Binary Format File

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 760
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 58
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: Convert an XML file into a Binary Format File

  #2  
Jan 4th, 2008
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(); 
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Join Date: Jan 2008
Location: Punjab(....India....)
Posts: 31
Reputation: btech_Saurabh is an unknown quantity at this point 
Rep Power: 1
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

  #3  
Jan 4th, 2008
Originally Posted by RamyMahrous View Post
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
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 760
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 58
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: Convert an XML file into a Binary Format File

  #4  
Jan 4th, 2008
Encrypt your data!!!
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Join Date: Jan 2008
Location: Punjab(....India....)
Posts: 31
Reputation: btech_Saurabh is an unknown quantity at this point 
Rep Power: 1
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

  #5  
Jan 4th, 2008
Thanx for the Nice Advice......but i have done it .....by using........BinaryFormatter.....
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 760
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 58
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: Convert an XML file into a Binary Format File

  #6  
Jan 4th, 2008
System.Security.Cryptography may help you for stronger and better encryption!
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Join Date: Jan 2008
Location: Punjab(....India....)
Posts: 31
Reputation: btech_Saurabh is an unknown quantity at this point 
Rep Power: 1
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

  #7  
Jan 4th, 2008
Thanx......Man
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C# Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C# Forum

All times are GMT -4. The time now is 6:08 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC