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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:57:53+00:00 2026-06-11T16:57:53+00:00

I have a handler that handles single files (text based) perfectly. I can receive

  • 0

I have a handler that handles single files (text based) perfectly. I can receive .zip files but they are unable to be accessed due to “corruption” errors. I know that this is due to reading things in as a text stream and not a byte array but I cannot figure it out. (My attempt is below)

EDIT:
I need to be able to have the handler accept .zips without corruption errors. I got past the corruption errors but the below code handles the file without corruption issues but unzips it with no files inside.

    Sub ProcessRequest(ByVal context as HttpContent) Implements IHTTPHandler.ProcessRequest

    Try
    If Context.Request.HttpMethod() = "POST" Then
    context.Response.ContentType = "application/octet-stream"
    context.Response.StatusCode = 204
    Dim reader as New System.IO.BinaryReader(context.Request.InputStream)
    Dim contents as Byte
    Dim int as Integer = reader.Basestream.Length

 ''Problem has got to be here, This loop structure can't be right..
    Do While int > 0
    contents = reader.readByte()
    System.IO.File.WriteAllText("thisismyoutputdirectory"), filename), contents)
    Loop
        else
    ''Handle non post cases
    end if

    Catch ex as Exception
    ''Error Handling is here
    End Try

    End Sub

Instead of Streamreader I am using BinaryReader. I have attempted to save contents as a byte array and then write them all out using the WriteAllBytes method.

I will continue experiementing but any guidance would be great!

  • 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-11T16:57:55+00:00Added an answer on June 11, 2026 at 4:57 pm

    I just solved the issue. I simply needed to write it out to a byte array and save an integer to represent the number of bytes. Then simply print the contents. It looks like I was trying to make things more complicated.

    My loop in original code is kinda ugly 🙁

    Sub ProcessRequest(ByVal context as HttpContext) Implements IHttpHandler.ProcessRequest
    
    Try
    
       ''If the handler receives a POST requent then perform these actions    
        If context.Request.HttpMethod() = "POST" Then
          context.Response.ContentType = "application/octet-Stream"
          context.Response.StatusCode = 204
          ''Get the filename out of the requests header
          Dim filename as String = context.Request.Header("filename")
          ''Get the numbytes for the .zip and save them as a byte array
          Dim numbytes as Integer = reader.BaseStream.Length
          Dim contents() as Byte = reader.ReadBytes(numbytes)
         ''Write the byte array out to the file
         System.IO.File.WriteAllBytes("This/is/my/path/" & filename, contents)
        else
        '' Handle has no work to do since request was not a POST
        End if
    
        Catch
        ''Error Handling is here
        End Try
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a download handler that will download the file when in IE but
We have a requirment which requires to have an Handler that is extended from
I have an event handler that needs to determine a type and execute code
I have an event handler that will remove an element from a list of
Suppose that I have a request handler that accepts an argument: key And let
I want to have an event handler that executes only once and then unbinds
In my Silverlight app I have an event handler that dynamically creates a new
I am using the ExtJS framework and I have the following handler that is
I have the following: <select id=price_select></select> I have an event handler that invokes the
I have a Handler class that looks like this: class Handler{ public $group; public

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.