Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the path that the application is running with typescript?

I am trying to create a desktop application with electron, angular2, typescript and neDB.In order to be able create a 'file' database with neDB I want the path to my project.How can I get this with typescript ?

like image 349
geo Avatar asked Sep 02 '25 05:09

geo


1 Answers

Use app.getAppPath()

Typescript is a superset of javascript so you could do it in the same way you would do it with javascript, though you may want to declare typings, or use other typescript features when you do so.

Example:

const remote = require('remote'), 
      app = remote.require('app');

var basepath = app.getAppPath();

Update - these days you should use:

const app = require('electron').remote.app

To get the app handle for app.getAppPath().

like image 56
Dan Avatar answered Sep 04 '25 22:09

Dan