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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:36:11+00:00 2026-06-12T19:36:11+00:00

This is my next question following writing a byte array from as string using

  • 0

This is my next question following writing a byte array from as string using an unknown dll

So I managed to write the byte array, now I want to read it back using the same dll.

I have tried the following:

int BufSize = 60000000;  // Size of file I/O buffers.
int BufSizeM1M = BufSize - 1000000; // The max amount of data read in at any one time.
using (WinFileIO WFIO = new WinFileIO())
{
    WFIO.OpenForReading(path);
    WFIO.ReadBlocks(BufSizeM1M);
    WFIO.Close();
    WFIO.Dispose();
}

this is the WinFileIO.ReadBlocks function:

public int ReadBlocks(int BytesToRead)
        {
            // This function reads a total of BytesToRead at a time.  There is a limit of 2gb per call.
            int BytesReadInBlock = 0, BytesRead = 0, BlockByteSize;
            byte* pBuf = (byte*)pBuffer;
            // Do until there are no more bytes to read or the buffer is full.
            do
            {
                BlockByteSize = Math.Min(BlockSize, BytesToRead - BytesRead);
                if (!ReadFile(pHandle, pBuf, BlockByteSize, &BytesReadInBlock, 0))
                {
                    Win32Exception WE = new Win32Exception();
                    ApplicationException AE = new ApplicationException("WinFileIO:ReadBytes - Error occurred reading a file. - "
                        + WE.Message);
                    throw AE;
                }
                if (BytesReadInBlock == 0)
                    break;
                BytesRead += BytesReadInBlock;
                pBuf += BytesReadInBlock;
            } while (BytesRead < BytesToRead);
            return BytesRead;
        }

My question is, how would one use the function to read an actual file?

  • 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-12T19:36:12+00:00Added an answer on June 12, 2026 at 7:36 pm

    To try and answer your question at a slightly higher level of abstraction, if you are working with an “unknown” .NET assembly, one thing you can try is to decompile the assembly and work out what is going on from the source.

    Decompilation is easier than it sounds. Just open the assembly (DLL) using the free tool ILSpy. You can then view the source for the methods you are trying to use in C# (or even CIL).

    Looking at the source code will let you see which parts of the .NET base class library are being used, and consult documentation for that, or even post another question here about the source code you do not understand.

    Without that source, all we can do is guess at the possible API and workflow your unknown assembly supports.

    In spite of my advice above, here is my guess:

    • looks like you are trying to read BufSizeM1M bytes from a file without checking it contains that much data.

    And here are a few other comments on your code:

    • you are calling WFIO.Dispose();, but WFIO is created in a using statement, so that line is unnecessary (this won’t be the error though).
    • it is possible (and desirable) that the WFIO.Close() is redundant when you are also having the object disposed.

    EDIT:

    So it looks like WinFileIO.ReadBlocks uses the Win32 ReadFile function to read BytesToRead bytes into a buffer pointed at by pBuffer. I guess you need to find another method on WinFileIO that gives you access to the buffer. The trick would be to look at which other methods do something with pBuffer. For example, there could be a method that converts it to a byte[] and returns it to you like that, and that might look something like this:

    public byte[] GetBuffer()
    {
        byte[] bytes=new byte[length];
        for(int i=0; i<length; i++)
        {
            bytes[i]=Marshal.ReadByte(pBuffer,i);
        }
        return bytes;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This helpful idea from Andy Gaskell supports 50% of my next question: I'd like
Im using the following JS <a href=# onClick=if($(this).next('div').css('display') == 'none') { $(this).next('div').show('fast'); } else
This is an extension / next step of this question I asked a few
This is a followup on the question: ASP.NET next/previous buttons to display single row
I am using this code: $('.ui-accordion').bind('accordionchange', function(event, ui) { $(this).next().next().css({'background-image':'images/green-bg.jpg'}); //ui.newHeader // jQuery object,
I have the following ajax call var prev_sibling = $(this).prev().attr(value); var next_sibling = $(this).next().attr(value);
I have the following jQuery which I need adapting: $(document).ready(function(){ $(.rss-popup a).hover(function() { $(this).next(em).stop(true,
I have the following function. $(function() { $(.sectionHeader:gt(0)).click(function() { $(this).next(.fieldset).slideToggle(fast); }); $(img[alt='minimize']).click(function(e) { $(this).closest(table).next(.fieldset).slideUp(fast);
First question from a long time user. I'm writing a Perl script that will
I am using Nvidia CG and Direct3D9 and have the question about the following

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.