Hello!, I'm just trying to write my string to a simple binary file so
it can't be read in a text document,, however it doesn't work.. I do
this
FileStream fs = File.Create(Server.MapPath("secret.txt"));
BinaryWriter bw = new BinaryWriter(fs);
bw.Write("You should not be able to read me");
bw.Close();
fs.Close();
It writes to it and all fine, but when I open the text file I can read
it fine. However, integers are displayed as gibberish. so its half
working.
Any help?
Thanks in advance. 4 1848
Bonzol <Bo****@hotmail.comwrote:
Hello!, I'm just trying to write my string to a simple binary file so
it can't be read in a text document,, however it doesn't work.. I do
this
FileStream fs = File.Create(Server.MapPath("secret.txt"));
BinaryWriter bw = new BinaryWriter(fs);
bw.Write("You should not be able to read me");
bw.Close();
fs.Close();
Firstly, I'd suggest using "using" statements to automatically close
your streams/writers, even if exceptions occur.
It writes to it and all fine, but when I open the text file I can read
it fine. However, integers are displayed as gibberish. so its half
working.
Any help?
I think you've misunderstood the point of BinaryWriter. It's not meant
to make things unreadable - it's just meant to be an easy way of
writing all kinds of values which can be read with BinaryReader.
If you're trying to keep data secret, you should use encryption
instead.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
On Jun 21, 4:35 pm, Jon Skeet [C# MVP] <s...@pobox.comwrote:
Bonzol <Bon...@hotmail.comwrote:
Hello!, I'm just trying to write my string to a simple binary file so
it can't be read in a text document,, however it doesn't work.. I do
this
FileStream fs = File.Create(Server.MapPath("secret.txt"));
BinaryWriter bw = new BinaryWriter(fs);
bw.Write("You should not be able to read me");
bw.Close();
fs.Close();
Firstly, I'd suggest using "using" statements to automatically close
your streams/writers, even if exceptions occur.
It writes to it and all fine, but when I open the text file I can read
it fine. However, integers are displayed as gibberish. so its half
working.
Any help?
I think you've misunderstood the point of BinaryWriter. It's not meant
to make things unreadable - it's just meant to be an easy way of
writing all kinds of values which can be read with BinaryReader.
If you're trying to keep data secret, you should use encryption
instead.
--
Jon Skeet - <s...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Im not that concerned with keeping data a secret, just want it to
appear unreadable when opend in a text document, and apparently this
method is supposed to do that,, but its not.
On Jun 21, 7:40 am, Bonzol <Bon...@hotmail.comwrote:
If you're trying to keep data secret, you should use encryption
instead.
Im not that concerned with keeping data a secret, just want it to
appear unreadable when opend in a text document, and apparently this
method is supposed to do that,, but its not.
What makes you think it's supposed to do that? Look at the
documentation for the method - it's doing exactly what it's meant to.
Jon
Hi,
"Bonzol" <Bo****@hotmail.comwrote in message
news:11**********************@e9g2000prf.googlegro ups.com...
On Jun 21, 4:35 pm, Jon Skeet [C# MVP] <s...@pobox.comwrote:
>Bonzol <Bon...@hotmail.comwrote:
Hello!, I'm just trying to write my string to a simple binary file so
it can't be read in a text document,, however it doesn't work.. I do
this
FileStream fs = File.Create(Server.MapPath("secret.txt"));
BinaryWriter bw = new BinaryWriter(fs);
bw.Write("You should not be able to read me");
bw.Close();
fs.Close();
Firstly, I'd suggest using "using" statements to automatically close your streams/writers, even if exceptions occur.
It writes to it and all fine, but when I open the text file I can read
it fine. However, integers are displayed as gibberish. so its half
working.
Any help?
I think you've misunderstood the point of BinaryWriter. It's not meant to make things unreadable - it's just meant to be an easy way of writing all kinds of values which can be read with BinaryReader.
If you're trying to keep data secret, you should use encryption instead.
-- Jon Skeet - <s...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too
Im not that concerned with keeping data a secret, just want it to
appear unreadable when opend in a text document, and apparently this
method is supposed to do that,, but its not.
That is not the use of it, as Jon pointed out it only intend to be able to
read/write any kind of binary data., if your data is only text most probably
it will write it like that. Do this, open an EXE in notepad and if you look
around you will see plain text around. Well the same happen in your case This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: john smith |
last post by:
Hi, I have a file format that is going to contain some parts in ascii, and
some parts with raw binary data. Should I open this file with ios::bin or
no?
For example:
filename: a.bin
number of...
|
by: Sebastian Kemi |
last post by:
How should a write a class to a file?
Would this example work:
object *myobject = 0;
tfile.write(reinterpret_cast<char *>(myobject), sizeof(*object));
/ sebek
|
by: Simon |
last post by:
Hi all,
I have a process, where I take a dataset from an SQL call, and need to write
an XML file from that dataset.
The data set can contain 10's of tables, each with 100's of rows, and I have...
|
by: rob |
last post by:
hey every1,
I've got alot of data to write out to file and it's all just 1's and
0's.
It's all stored in 2 dimensional arrays of width 32 and varying
height.
At the moment it's all just...
|
by: Romain |
last post by:
Hello,
I am writing out a binary file. I figured that the number "10" is
automaticaly converted to "OD OA" instead of "OD". "OD" and "OA" are
line feed and carriage return.
I know it does...
|
by: DanielEKFA |
last post by:
Hey there :)
I was once told that the STL classes had member functions to write their
data to disk and to restore that data. Searching google (and why are there
no "stl" or "map" manpages?), it...
|
by: Jeevan |
last post by:
Hi,
I have an array of data (which I am getting from a socket connection).
I am working on a program which acts on this data but the program is
written to work on data from a file (not from an...
|
by: nicolasg |
last post by:
Hi,
I'm trying to open a file (any file) in binary mode and save it inside
a new text file.
After that I want to read the source from the text file and save it
back to the disk with its...
|
by: arne.muller |
last post by:
Hello,
I've come across some problems reading strucutres from binary files.
Basically I've some strutures
typedef struct {
int i;
double x;
int n;
double *mz;
|
by: zehra.mb |
last post by:
Hi,
I had written application for storing employee data in binary file and
reading those data from binary file and display it in C language.
But I face some issue with writing data to binary file....
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |