Creating and Writing Files with electron

in #utopian-io6 years ago (edited)

electron.png

What Will I Learn?

  • You will learn Create an electron Application
  • You will learn How to create files with electron
  • You will learn How to write data to the file with electron

Requirements

.

Difficulty

  • Intermediate

Description

In this video will show you how to create files and wirte data to file with electron
First I will create a user registration form. The user information will be entered in this form and then the information will be saved in the file according toy he json format.
Form editing operaions using Bootstrap and file operations using Jquery so Bootstrap and Jquery must be installed.
I have already written the codes necessary to run electron application here
1.jpg
Let coding
First define a container

2.jpg

Where I will create four form-group

3.jpg

Create a button

4.jpg

This button will both create the file and write it to the file
I set the view.js
I will define Jquery to use , and defien a file system

5.jpg

Let’s name the file we will use

7.jpg

Let’s create the file create a function for it and check if file exist

8.jpg
If there is no file named contacts the file is begin created and the console is begin printed
If contacts has a named file the file is not created again

Now, when we click on the button we write the data file

9.jpg

Here we got the values of the inputs
Finally I print this data to file

Code Samples

const {app, BrowserWindow} = require('electron')
const url = require('url')
const path = require('path')

let win

function crtWindow() {
win = new BrowserWindow({
width: 800, height: 600
})
win.loadURL(url.format ({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))

win.openDevTools();
}

app.on('ready', crtWindow)

Github Project File

Video Tutorial

Sort:  
Loading...

Congratulations @sanalrakam! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.

To support your work, I also upvoted your post!
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Coin Marketplace

STEEM 0.27
TRX 0.13
JST 0.032
BTC 62423.21
ETH 2897.82
USDT 1.00
SBD 3.56