0

Currently I am building a local (non-internet) application that launches a Chromium browser in Visual Basic .NET.

It uses CefSharp to achieve this.

When the HTML launches I need to read multiple files in order to plot graphs using Plotly.

The problem: I can't read binary files.

I have succeeded in reading ASCII and non-binary files, by disabling security on CefSharp. I tried using the FolderSchemeHandlerFactory class, but that didn't work.

In order to read ASCII files I have resorted to using XMLHttpRequest which works for ASCII , but not binary. I have tried changing the response type to arraybuffer, but that doesn't work either.

function readTextFile(file){    
    var array = []
    var file= new XMLHttpRequest();
    file.open("GET", file, false);
    file.onreadystatechange = function ()
    {
        if(file.readyState === 4)
        {
                if(file.status === 200 || file.status == 0)
                {
                var text= file.responseText;
                array = text.split("\n");
            }
        }
    }
    file.send(null);    
    return array;
}
Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Pman6543
  • 11
  • 3
  • 2
    Well, if you use the property `responseText`, it's going to give you ... text. You probably want [`response`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/response), which will give you an `ArrayBuffer`. Or use [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), which has a `response.arrayBuffer()` method on it. – Heretic Monkey Jun 07 '19 at 21:47
  • 1
    Possible duplicate of [Downloading binary data using XMLHttpRequest, without overrideMimeType](https://stackoverflow.com/questions/7255719/downloading-binary-data-using-xmlhttprequest-without-overridemimetype) – Heretic Monkey Jun 07 '19 at 21:49

0 Answers0