How can I get information about the file that launched my app?

user773737

Similar to How to get the arguments for opening file with electron app but the solution there is not working for me.

Using:
OS - Windows 10
Electron - https://github.com/castlabs/electron-releases.git#v1.8.7-vmp1010
electron-builde - v20.28.3

I have a an electron app build with electron-builder, and using the latter I have specified a custom file association, .custom.

So when you double-click on a file with this extension, file.custom, the installed app opens. This file would have some data in it that the app needs, and I'd like to read this data using my app.

Is there any way that my app can detect what launched it, so that I can say "file.custom" launched me, and it's sitting at "C:\Users\Owner\Downloads\,?

The file does not appear in process.argv

Rapwnzel

You can get a reference to the file using process.argv, example:

var ipc = require('ipc');
var fs = require('fs');

// read the file and send data to the render process
ipc.on('get-file-data', function(event) {
    var data = null;
    if (process.platform == 'win32' && process.argv.length >= 2) {
        var openFilePath = process.argv[1];
        data = fs.readFileSync(openFilePath, 'utf-8');
    }
    event.returnValue = data;
});

source: Source

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I get information about type of a Go variable

How can I get my .NET Core 3 single file app to find the appsettings.json file?

how can I send log information from my Android app to my server?

How can I get WiFi Network information (SSID) in a Phonegap app?

How can I get the information about an individual IM in the Slack API?

How can I get data from a local file into my React app?

Can I detect if my PWA is launched as an app or visited as a website?

How can I use an uploaded CSV file in my flask app?

How can I get this App Store purchase window in my app?

How can i get information with javascript about the device which the user used to get on my asp.net webapp?

How can i get information about in-app-purchases in Google Play Billing for android

How can I know that my app was opened by Google Assistant, instead of just normally launched

is there anyway I can get information about vkimage?

How do I get the information about each branch of my git local repository

How can I get information about children of some StorageReference?

How can I find out what .desktop file is being launched?

How can I get information about my virtual desktops via the command line?

Get information about my PSU

How can I upload a GarageBand (.band) file into my rails app?

How can I get a picture file from an app I downloaded on my phone?

How can I get informations within code about the cache of my app?

In FUSE, how do I get the information about the user and the process that is trying to read/write in the virtual file system?

I've launched a .cmd file from somewhere in my %PATH% How can I know the location of the file?

How can i get the correct information to display in my listbox?

Get information about file

How can I set the resolution and rotate the screen of an app launched with startx

How can I get information about store users in BigCommerce?

How do I get information about the server my app is running on in spring boot?

How do i get information from my app config in my app script?