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 8723919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:43:28+00:00 2026-06-13T07:43:28+00:00

Hi I am reading a audio file into a byte array. then i want

  • 0

Hi I am reading a audio file into a byte array. then i want to read every 4 bytes of data from that byte array and write it into another file.

I am able to do this but, my problem is i want to add new line aft every 4 byte of data is written to file. how to do that??
Here is my code…

FileStream f = new FileStream(@"c:\temp\MyTest.acc");
for (i = 0; i < f.Length; i += 4)
{
    byte[] b = new byte[4];
    int bytesRead = f.Read(b, 0, b.Length);

    if (bytesRead < 4)
    {
        byte[] b2 = new byte[bytesRead];
        Array.Copy(b, b2, bytesRead);
        arrays.Add(b2);
    }
    else if (bytesRead > 0)
        arrays.Add(b);

    fs.Write(b, 0, b.Length);
}

Any suggestions please.

  • 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-13T07:43:29+00:00Added an answer on June 13, 2026 at 7:43 am

    I think this might be the answer to your question:

                byte[] newline = Encoding.ASCII.GetBytes(Environment.NewLine);
                fs.Write(newline, 0, newline.Length);
    

    So your code should be something llike this:

                FileStream f = new FileStream("G:\\text.txt",FileMode.Open);
                for (int i = 0; i < f.Length; i += 4)
                {
                    byte[] b = new byte[4];
                    int bytesRead = f.Read(b, 0, b.Length);
    
                    if (bytesRead < 4)
                    {
                        byte[] b2 = new byte[bytesRead];
                        Array.Copy(b, b2, bytesRead);
                        arrays.Add(b2);
                    }
                    else if (bytesRead > 0)
                        arrays.Add(b);
    
                    fs.Write(b, 0, b.Length);
                    byte[] newline = Encoding.ASCII.GetBytes(Environment.NewLine);
                    fs.Write(newline, 0, newline.Length);
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to send the audio data in byte array obtain by recording from
I have an MP3 audio file that I want to play from my Android
I am reading a raw audio file (CD track rip) in, doing byte swapping,
I am modifying an application that plays audio data to write the data to
I am trying to extract level data from a PCM audio file using core
I am currently reading audio floats from a file using Dirac's (OSStatus) readFloatsConsecutive:(SInt64)numFrames intoArray:(float**)audio
Dupe of calculate playing time of a .mp3 file im reading a audio file(for
Total noob to anything lower-level than Java, diving into iPhone audio, and realing from
Are there any audio formats that are stored in a plain text file? For
I'm analyzing music mp3 files. What I'm doing is extracting the audio data from

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.