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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:07:19+00:00 2026-06-14T20:07:19+00:00

I have this function to write bytes in a bin file. Public Shared Function

  • 0

I have this function to write bytes in a bin file.

    Public Shared Function writeFS(path As String, count As Integer) As Integer
        Using writer As New BinaryWriter(File.Open(path, FileMode.Open, FileAccess.Write, FileShare.Write), Encoding.ASCII)
            Dim x As Integer
            Do Until x = count
                writer.BaseStream.Seek(0, SeekOrigin.End)
                writer.Write(CByte(&HFF))
                x += 1
            Loop
        End Using
        Return -1
    End Function

I have a textBox that is the count value. Count is the number of byte to write into the file.

The problem is when i want to write 1mb+ it take like 10+ seconds because of the cycle.

I need a better/faster way to write hex value FF at the end of file 'value' times.

I’m sorry if i’ve not explained very well.

  • 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-14T20:07:20+00:00Added an answer on June 14, 2026 at 8:07 pm

    This should be better:

    Public Shared Function writeFS(path As String, count As Integer) As Integer
        Using writer As New BinaryWriter(File.Open(path, FileMode.Open, FileAccess.Write, FileShare.Write), Encoding.ASCII)
            Dim x As Integer
            Dim b as Byte
            b = CByte(&HFF)
            writer.BaseStream.Seek(0, SeekOrigin.End)
            Do Until x = count
                writer.Write(b)
                x += 1
            Loop
        End Using
        Return -1
    End Function
    

    That way you’re not calling CByte every time. And there is no need to move to the end of the stream after each write.

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

Sidebar

Related Questions

I have an XOR encypted file by a VB.net program using this function to
I have this code which works well: Public Function LoadBinaryFile(strFilename As String) As Byte()
I have this function to create a request to another file to update the
I have this function in my js file. I need to give time for
Hi' i have permission denied when using write to text function like file_put_contents. i'm
I have this PHP function (using PHP 5.3) that I use to decrypt files,
I have a simple file transfer application, which transfers 4096 bytes per write from
I have a simple function to create a gzip file. This function work fine
I would like to write the function which takes file size in bytes(7762432) and
i have locked my file from 0 to 5 bytes, and i write some

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.