working-directory

What would cause the current directory of an executing app to change?

I have a C# application that includes the following code: string file = "relativePath.txt"; //Time elapses... string contents = File.ReadAllText(file); This works fine, most of the time. The file is read relative to the directory that the app was started from. However, in testing, it has been found that if left alone for about 5 h...

Getting process information in .NET

Duplicate of this question. update - This is not an exact duplicate. See my solution. I see a java.exe process in process explorer, and double clicking it gives me its working directory & starting command line arguments. From .NET, I run the following code and get a process with the same PID but the above fields are empty. Apparently,...

Changing the current working directory in Java?

How can I change the current working directory from within a Java program? Everything I've been able to find about the issue claims that you simply can't do it, but I can't believe that that's really the case. I have a piece of code that opens a file using a hard-coded relative file path from the directory it's normally started in, and ...

Can the working directory be set in the project (.vcproj) file?

I have a script that generates a .sln file and a few .vcproj files for visual studio 2005. I need to set the WorkingDirectory option but its specified in the .user file. A file we cannot currently generate. I found the vcproj file definition at msdn, but it seems that this option cant be set from there. How does one specify "Configura...

SVN Weirdness: Is It Possible It's Not My Fault

(I don't really care if it's my fault but rather why things are happening, of course...) I have a rails site in SVN on a remote server. On my local copy I do a switch (svn switch http://whatever/branch .), and then things are totally bizarre and the site doesn't work. I finally track it down and it turns out that part of the build (part...

Runtime directory of Python

How do I find out the current runtime directory from within a Python script? ...

system("c:\\sample\\startAll.bat") cannot run because of working directory?

Hi, I have an application and executables. I want my application to run my executables. The executable files are in a folder, lets say in "c:\sample". In this directory there is a batch file that calls my exe's. like: start a1.exe start a2.exe start a3.exe let's name it as startAll.bat and suppose every exe has a data like a1.dat a...

How to get R to recognize your working directory as its working directory?

I use R under Windows on several machines. I know you can set the working directory from within an R script, like this setwd("C:/Documents and Settings/username/My Documents/x/y/z") ... but then this breaks the portability of the script. It's also annoying to have to reverse all the slashes (since Windows gives you backslashes) Is th...

Java: Howto know where the jar is located in Linux

Hello, In Linux, the JVM sets the working direcory equal to the homefolder from the user. In Windows is this the folder where the jar is located. How can I find where the jar (from my app) is located to change the working dir? Martijn ...

python: Change the scripts working directory to the script's own directory

Hi, I run a python shell from crontab every minute: * * * * * /home/udi/foo/bar.py /home/udi/foo has some necessary subdirectories, like /home/udi/foo/log and /home/udi/foo/config, which /home/udi/foo/bar.py refers to. The problem is that crontab runs the script from a different working directory, so trying to open ./log/bar.log fai...

Python: execfile from other file's working directory?

I have some code that loads a default configuration file and then allows users to supply their own Python files as additional supplemental configuration or overrides of the defaults: # foo.py def load(cfg_path=None): # load default configuration exec(default_config) # load user-specific configuration if cfg_path: ...

how to get the current working directory's absolute path from irb

I'm running Ruby on Windows though I don't know if that should make a difference. All I want to do is get the current working directory's absolute path. Is this possible from irb? Apparently from a script it's possible using File.expand_path(FILE) But from irb I tried the following and got a "Permission denied" error: File.new(Dir.n...

C++ Portable way of programmatically finding the executable root directory

Possible Duplicate: how to find the location of the executable in C Hi, I am looking for a portable way to find the root directory of a program (in C++). For instance, under Linux, a user could copy code to /opt, add it to the PATH, then execute it: cp -r my_special_code /opt/ export PATH=${PATH}:/opt/my_special_code/ cd /ho...

howoto fix working directory is always home? (python)

Hello guys! This is my first question. My python script opens and reads from a present text file using the following simple funct: open("config.ini", "r") As this is a relative path it is supposed to work because config.ini is placed in the same directory like the script is when it is launched, that should be the current working dir....

How to define working directories for DLL dependencies in Visual Studio / C#

Hello, I've got an executeable file, which I run for example from C:. The executable references some DLLs from another directory, let's say C:\MyDLLs. The problem is, that these referenced DLLs again depend on other DLLs, which are stored in another directory. Can I tell Visual Studio where to look for these missing DLLs? Thanks a lot! ...

How make working directory files available to WebStart application?

Hello everyone, We have to make a Java application demo available on Internet using JWS. It goes pretty well; all that's missing is making working directory files available for the application. We know about the getResource() way... The problem is that we have different plugins for the same application and each one require different fi...

Change program's working directory in compile-time in Visual C++

Is there a way to define a program's working directory to be different from its current directory at compile-time, on Visual C++? The bosses want the executable to be on the root directory but all DLLs to be in a separate dir. ...

How can I change the current directory in a thread-safe manner in Perl?

I'm using Thread::Pool::Simple to create a few working threads. Each working thread does some stuff, including a call to chdir followed by an execution of an external Perl script (from the jbrowse genome browser, if it matters). I use capturex to call the external script and die on its failure. I discovered that when I use more then one...

subprocesses with different working directories problem with python.

I am working under the following project directory. work/project/test/a.py then, inside a.py, I have to use the subprocess.POPEN to launch the process from another directory, work/to_launch/file1.pl, file2.py, file3,..., (note: the file1.pl will call file2.py, file3. etc) e.g. inside a.py, I use subprocess.POPEN("usr/bin/perl ....