How to read a local file in Javascript (Running from an Electron App)

I have been searching for over an hour or so, and I cant find an answer to my question. Is there a way to get the text from a local file, using just a plain old file URL?

I have found numerous ways to read a file via file input HTML tag, but I have had an incredible pain, finding a code example that can find a file, on my PC, using just plain old JS.

The code will be inside an electron application.

I need code examples. Something like this:

readFile("file:\\\\C:\path\to\file.txt","text/plain");

readFile(url,mimetype){
 ....
}

15 thoughts on “How to read a local file in Javascript (Running from an Electron App)”

Leave a Comment