Skip to content

Prevent sqlite db to overwrite while installing my ElectronNet application #743

@krishrana17

Description

@krishrana17

I am developing an Electron.NET application using .NET Core 6 and I want to prevent my SQLite database file from being overwritten during the installation process if it already exists. I have added the necessary code to my manually created 'main.js' file to check for the existence of the file and copy it only if it doesn't exist. However, when I build the package using 'electronize build /target win', the code in my 'main.js' file is not reflected in the built package. Is this a bug or am I missing something?

`const fs = require('fs');
const path = require('path');
const { app } = require('electron');

// Get the installation directory
const appPath = app.getPath('exe');
const installDir = path.dirname(appPath);

// Check if the database file already exists
const dbFile = path.join(installDir, 'mydb.sqlite');
if (!fs.existsSync(dbFile)) {
const resourcePath = path.join(__dirname, 'mydb.sqlite');
fs.copyFileSync(resourcePath, dbFile);
}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions