Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently attempting to use .NET/link to call a third party DLL from Mathematica using DLLDefinedFunction. I have been able to link against and call many of the functions in the DLL, but have encountered issues with one function in particular, which attempts to read in data from a file whose path is hard-coded relative to the current working directory.

Forgive my ignorance, but as I am not "au fait" with .NET, I don't know how to determine what InstallableNET32.exe is using as its working directory, or how to change it to something else. (I do know how to change the working directory for the MathKernel, but based on my experimentation, any changes to the kernel's working directory do not appear to "flow through" to the InstallableNET runtime.)

Could someone please provide guidance on how I can identify, and then change, the working directory being used by the InstallableNET runtime (Is this an example of another undocumented feature in .NET/link, like the "Force32Bit"->True option?)

share|improve this question
up vote 3 down vote accepted

I googled ".net change working directory", and this link to Microsoft's .NET docs was the first hit: It would suggest the following:


To find out the current working directory:

share|improve this answer
Todd: Thanks, this works. I had tried something similar, but was attempting to load "System.IO" only. I did say I wasn't at all familiar with .NET ... ;-) – Confused-cius Dec 18 '13 at 18:09

This may be what you're looking for or at least help slightly...

You would need to load the System.IO.Directory class and call the static SetCurrentDirectory method on it.

Alternatively I believe you can set it (dim distant memory) in the InstallableNet.exe.xml (or InstallableNET32.exe.xml) file located in C:\Program Files\Wolfram Research\Mathematica\9.0\SystemFiles\Links\NETLink which would then make it a default. If its not set anywhere it defaults to the location the .NET runtime executed from.

share|improve this answer
Ymareth: Thanks. The System.IO.Directory approach works (as also pointed out by Todd above). I had a quick look in the .xml config files you mentioned, but can't confirm or deny whether an appropriate edit in these files would work. – Confused-cius Dec 18 '13 at 18:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.