问题标签 [working-directory]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
34270 浏览

java - Can you set the current running directory from the java command line?

I am running a Java application from the command line. Can I specify a command line argument to set the current running directory to something other than where the application is actually going to run?

0 投票
1 回答
1060 浏览

appdomain - Separate working directories between appdomains

I have a .NET application that is creating several separate AppDomains to run some plugginable code, each of the AppDomains sets up its own WCF named pipes service to communicate with the central application.

However I want to set a different working directory for each AppDomain, so that the base folder of any relative path is different in each app domain. So these plugins can create its own folder structure in all the normal file handling ways by going "./MyCustomFolder".

Unfortunately I am finding Directory.SetWorkingDirectory() is setting it for the whole process (not isolated to a single app domain) this is causing some plugins to write in other plugin directories.

Is it possible to change the working directory for different AppDomains, or do I need to kick off brand new processes to do what I'm after? If I need whole processes to do what Im after what is your opinions on trying to manage parent / child processes effectively in a stable way?

0 投票
3 回答
6566 浏览

python - 如何在 Python 'os' 模块的函数中引用当前目录?

我想使用该函数os.listdir(path)从运行脚本的目录中获取文件列表,但是如何在“路径”参数中说出当前目录?

0 投票
5 回答
52196 浏览

c++ - 如何找到当前目录?

我正在尝试读取我之前成功读取的文件。我正在通过图书馆阅读它,并将它按原样发送到图书馆(即“myfile.txt”)。我知道该文件是从工作/当前目录中读取的。

我怀疑当前/工作目录已经以某种方式发生了变化。我如何检查当前/工作目录是什么?

0 投票
3 回答
3321 浏览

python - Python:是否可以在不更改实际当前目录的情况下更改 Windows 命令行 shell 当前目录?

os.system()用来执行 Windows 命令行 shell 执行。我想更改 Windows cmd 当前目录。这是一种方法:

chdir()也会改变实际的 Python 当前工作目录。我不想更改实际的 Python 工作目录,因为我希望脚本的其他部分在原始当前工作目录中运行。我要更改的只是 Windows cmd 当前工作目录。换句话说:我希望os.system()命令在一个当前工作目录(Windows cmd 当前工作目录)中运行,而其他任何东西都应该在另一个当前工作目录(实际的 Python 当前工作目录)中运行。

这是仅更改Windows cmd 当前目录的另一种尝试:

但是,这显然不起作用,因为在执行cd newPath命令后,Windows cmd 当前目录被重置(因为我不会在下一次调用时使用相同的 Windows 命令 shell os.system())。

是否可以为 Windows cmd shell 提供一个单独的当前工作目录?(与实际的当前工作目录分开)。

0 投票
2 回答
1405 浏览

c++ - 工作目录

如何使工作目录成为“调试目录”,但不是通过属性,而是通过代码?

0 投票
1 回答
336 浏览

c++ - 工作目录 - 解决方案

如何使工作目录成为“解决方案目录”,但不是通过属性,而是通过代码?

我在 Windows 中工作。

0 投票
2 回答
1350 浏览

objective-c - Objective-C 和 Xcode 中的工作目录:调试模式与可执行文件

我正在使用 Xcode 在 Objective-C 中编写程序。我的程序创建一个文件如下:

我希望将文件创建在与可执行文件相同的目录中。当我从 Xcode 运行程序时,该文件按预期在调试目录中创建。

但是,当我运行 .app 文件时,该文件是在根目录中创建的。如何让程序在 .app 文件所在的目录中创建文件。

非常感谢。

编辑:这是一个 MacOS 应用程序

EDIT2:好吧,看来我不应该写入 .app 目录。谢谢bbum和Paul R。正确的方法是什么?更具体地说,这就是我正在做的事情:每次用户单击应用程序中的按钮时,连接到串行端口的一块硬件将发送一堆数据,这些数据将被写入一个新文件。这可能在应用程序运行时发生任意次数,因此可能会创建大量文件。我希望它们都在同一个文件夹中创建。

0 投票
1 回答
331 浏览

process - 获取进程的初始工作目录和可执行文件名?

有没有办法安全地获取初始工作目录和进程的可执行名称?“初始工作目录”是指进程首次生成和执行时的当前工作目录,“安全”是指被检查的进程不能更改从该进程地址空间之外观察到的值。该进程的进程ID是预先知道的。

http://www.lindevdoc.org/wiki//proc/PID/exe描述了如何获取进程的可执行名称,但这安全吗?

我还没有找到一种方法来安全地获取进程的初始(但不一定是当前)工作目录。这可以在不修改内核的情况下实现吗?

编辑:语言是 C,平台是 Linux(我试图在 FUSE 文件系统中实现它)。

0 投票
3 回答
2656 浏览

terminal - AppleScript:如何获取最顶层终端的当前目录

我想获取最顶层终端选项卡/窗口的当前目录(通过 AppleScript 或其他方式,这并不重要)。我怎样才能做到这一点?