Text File to Binary

M

Mythran

Stuck.

I have a bunch of rather large text files filling up space that will be archived
and stored for future references. These are all XML files that are 10+ mb each
(not too big but not small either). Is there a way to convert these xml files to
binary which would make the file smaller? If so, how?

I've taken a look (and tested) the Text.Encoding classes/methods and was able to
convert to binary (but of course they were still all text). So, just writing
through a binary stream wasn't enough. I tried using convert() to convert to a
different encoding, but then again, that's not converting to binary, just UTF8,
7, ascii or unicode.

Also, we do not want it readable by text editors. As in, if someone opened it up
in a text editor, it would look garbled (hence, binary format). This is a
separate need and we can encrypt if required, just need to figure out the above
questions first. =p)


Mythran
 
H

Herfried K. Wagner [MVP]

* "Mythran said:
I have a bunch of rather large text files filling up space that will be archived
and stored for future references. These are all XML files that are 10+ mb each
(not too big but not small either). Is there a way to convert these xml files to
binary which would make the file smaller? If so, how?

You could ZIP them:

<URL:http://www.icsharpcode.net/OpenSource/SharpZipLib/>
 
M

Mythran

Oh well.

How about (instead of compressing) somehow scrambling them or something so
we can make them binary (basically, what we need is when we view them in
notepad...they should not be readable/plain text.)

Thanks,
Mythran
 
C

Cor Ligthert

Hi Mythran,

What is the difference from what you write and making a Zip file?

Cor
 
H

Herfried K. Wagner [MVP]

* "Mythran said:
How about (instead of compressing) somehow scrambling them or something so
we can make them binary (basically, what we need is when we view them in
notepad...they should not be readable/plain text.)

Maybe encryption, but you need a way to recover the XML data, so
compression, maybe using a password, is IMO the easiest way.
 
M

Mythran

On linux, and c, I can open a file as binary, write to it a large string,
close it and then open it in a text editor and not be able to read the
contents. So, I'm guessing this is all part of linux or c and not something
we have as an immediate option in VB.Net?

thanks,

Mythran
 
C

Cor Ligthert

Hi Mythran,

When you read an A as an a and write it to file as an byte with the decimal
value 65 it will stay an A.

You need some conversion, however that showed Herfried in my opinion.
(You can use of course also the encryption classes like Rijndael)

Cor
 
H

Herfried K. Wagner [MVP]

* "Mythran said:
On linux, and c, I can open a file as binary, write to it a large string,
close it and then open it in a text editor and not be able to read the
contents.

Mhm... What command do you use to write the file?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top