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

  • Home
  • SEARCH
  • 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 3451534
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:09:20+00:00 2026-05-18T09:09:20+00:00

I’m reading in a text file using BinaryReader, then doing what I want with

  • 0

I’m reading in a text file using BinaryReader, then doing what I want with it (stripping characters, etc..), then writing it out using BinaryWriter.

Nice and simple.

One of the things I need to do before I strip anything is to:

  1. Check that the amount of characters in the file is even (obviously file.Length % 2) and

  2. If the length is even, check that every preceding character is a zero.

For example:

0, 10, 0, 20, 0, 30, 0, 40.

I need to verify that every second character is a zero.

Any ideas? Some sort of clever for loop?

OKAY!

I need to be a lot more clear about what I’m doing. I have file.txt that contains ‘records’. Let’s just say it’s a comma delimited file. Now, What my program needs to do is read through this file, byte by byte, and strip all of the characters we don’t want. I have done that. But, some of the files that will be going through this program will be single byte, and some will be double byte. I need to deal with both of these possibilities. But, I need to figure out whether the file is single or double byte in the first place.

Now, obviously if the file is double byte:

  1. The file length will be divisible by 2 and
  2. Every preceding character will be a zero.

and THAT’S why I need to do this.

I hope this clears some stuff up..

UPDATE!

I’m just going to have a boolean in the arguments – is16Bit. Thanks for your help guys! I would have rather deleted the question but it won’t let me..

  • 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-05-18T09:09:20+00:00Added an answer on May 18, 2026 at 9:09 am

    Something like this in a static class:

    public static IEnumerable<T> EveryOther(this IEnumerable<T> list)
    {
       bool send = true;
       foreach(var item in list)
       {
          if (send) yield return item;
          send = !send;
       }
    }
    

    and then (using the namespace of the previous class)

    bool everyOtherIsZero = theBytes.EveryOther().All(c => c == 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.