Reading Data From File with Electron

Repository

https://github.com/electron/electron

What Will I Learn?

  • You will learn to create an electron application
  • You will learn how to read files with electron

Requirements

Difficulty

  • Intermediate

Description

  • In this video I will show you how to read data from file operations with electron
    I will create the data reading codes from the file using the file system codes in nodejs
    I have created an example for you to better understand the subject

STEP 1

I have added one file containing the data the name of the file contacts
The data holds the information of the users
Our application will allow us to login the user using this data

STEP 2

I will design a page that request a username and password
I will print success if the Values entered are equal to the Values in the file
İf it is not equal I will write an error

Let’s start

Firstly I will show the codes I wrote

1.jpg

I wrote the user name and password field
and create a button and message label
I will do the codes create a page named a view.js
Define a Jquery and file system

2.jpg
Let’ s keep the name of the contacts file in filename
3.jpg
Catch the moment when button is clicked
4.jpg

Define username and password input

5.jpg

6.jpg

I will desşgn the button and input Bootstrap so I wrote the Bootstrap extension

So we can now capture the Values entered into the inputs
Now we read all the data in the file

7.jpg

Converted to utf8 format
I defined an array based on the space
Let’s write the console at thesame time
We can now return in this array

8.jpg

Then we split the data by comma we can Access all the information of a user
So we named each field
There are two areas as seen, the first domain represent the name and the second field represent value
Operator colon separeting these two fields

9.jpg

Let’s check whether the data in the file is written to the input equally

10.jpg

İf it is equal to flag value
Set i=1;

İf i value one is success else print error

11.jpg

Video Tutorial

Github Project Link

Curriculum

IPC in Electron Tutorial
The Remaining Character Calculation Application in the electron

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center