Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8516869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:32:54+00:00 2026-06-11T05:32:54+00:00

I want to create a binary file and store string data in it, I

  • 0

I want to create a binary file and store string data in it, I used this sample:

FileStream fs = new FileStream("c:\\test.data", FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(Encoding.ASCII.GetBytes("david stein"));
bw.Close();

but when I opened created file by this sample (test.data) in notepad, it has string data in it (“david stein”), now my question is that whats the difference between this binary writing and text writing when the result is string?

I’m looking to create a data in binary file until user can not open and read my data by note pad and if user open it in notepad see real binary data .

in some files when you open theme in text editors you can not read file content like jpg files contents,they do not use any encryption methods,what about it?how can i wite my data like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:32:56+00:00Added an answer on June 11, 2026 at 5:32 am

    now my question is that whats the difference between this binary writing and text writing when the result is string?

    The data in a file is always “a sequence of bytes”. In this case, the sequence of bytes you’ve written is “the bytes representing the text ‘david stein'” in the ASCII encoding. So yes, if you open the file in any editor which tries to interpret the bytes as text in a way which is compatible with ASCII, you’ll see the text “david stein”. Really it’s just a load of bytes though – it all depends on how you interpret them.

    If you’d written:

    File.WriteAllText("c:\\test.data", "david stein", Encoding.ASCII);
    

    you’d have ended up with the exact same sequence of bytes. There are any number of ways you could have created a file with the same bytes in. There’s nothing about File.WriteAllText which “marks” the file as text, and there’s nothing about FileStream or BinaryWriter which marks the file as binary.

    EDIT: From comments:

    I’m looking to create a data in binary file until user can not open and read my data by note pad

    Well, there are lots of ways of doing that with different levels of security. Ideally, you’d want some sort of encryption – but then the code reading the data would need to be able to decrypt it as well, which means it would need to be able to get a key. That then moves the question to “how do I store a key”.

    If you only need to verify the data in the file (e.g. check that it matches something from elsewhere) then you could use a cryptographic hash instead.

    If you only need to prevent the most casual of snoopers, you could use something which is basically just obfuscation – a very weak form of encryption with no “key” as such. Anyone who dceompiled your code would easily be able to get at the data in that case, but you may not care too much about that.

    It all depends on your requirements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a pdf file from Binary data. I looked around and
I want to create a Binary file of my project. I have set my
I have an input stream from a binary file. I want to create a
I just want to create an RPM file to distribute my Linux binary foobar,
I want to create a hex dump of a binary file in Mac OS
I want to create a binary file from a C file using ubuntu. I
I'm trying to create my own file format. I want to store image file
If I want to save binary to Azure Table, when I create a class
i want create a custom json data from the mssql 2008 results so that
i want create Dynamic Slideshow in Jquery i'm Write this code var ctx =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.