如何获取应用程序正在使用Typescript运行的路径? [英] How can I get the path that the application is running with typescript?

查看:647
本文介绍了如何获取应用程序正在使用Typescript运行的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个带有电子,angular2,打字稿和neDB的桌面应用程序.为了能够使用neDB创建一个'文件'数据库,我想要我的项目的路径.如何使用打字稿来获得它?

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 ?

推荐答案

使用 app.getAppPath()

Typescript是javascript的超集,因此您可以用与javascript相同的方式进行操作,尽管您可能想声明类型或使用其他类型的脚本功能.

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.

示例:

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

var basepath = app.getAppPath();

更新-这些天您应该使用:

Update - these days you should use:

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

获取app.getAppPath()的应用句柄.

这篇关于如何获取应用程序正在使用Typescript运行的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆