Skip to content
Advertisement

Electron function to read a local file – FS – Not reading

I have an electron project when I need to get electron to read a local file.

Right now what I have is this, where it loads and displays the contents of a html file.

I just need it to read a file and store it on a variable for now.

Here is my current main.js:

JavaScript

How can I do this as it’s not showing the contents of the README.md file in the console.log

Advertisement

Answer

Basically you need to do the following things.

1.Loading required dependencies

JavaScript

2.Read file content

JavaScript

3.Update existing file content

JavaScript

For more read please visit here 🙂 Thanks..

One more thing to add..Please check that your path to file is correct. You could do something similar to below.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement