Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Hello Mathematica users,

I have problem to set working directory, I want to calculate and save my data on D, but down you can see that mathematica shift automatically on old C. How to use D partition for calculating if mathematica is installed on C?

If I do calculation as this, file is saved on D but first it is saved on C and on C I don't have enough space.

  In[7]:= ResetDirectory[] 


  In[8]:= DirectoryStack[]

  Out[8]= {}

  In[10]:= SetDirectory["D:\\"]

  Out[10]= "D:\\"


  Export["A.wdx", A];

  In[13]:= DirectoryStack[] 

share|improve this question
What is the value of $TemporaryDirectory? –  celtschk May 2 '12 at 21:34
Can you change SetDirectory["D:\\"] to SetDirectory[$TemporaryDirectory] and rerun the whole program? –  qazwsx May 2 '12 at 21:43
As reality check, have a look if and where "A.wdx" is in fact saved...? –  Yves Klett May 3 '12 at 9:43

2 Answers 2

The Documentation page for ResetDirectory says under "MORE INFORMATION" field:

Successive calls to ResetDirectory yield earlier and earlier current directories.

ResetDirectory uses the directory stack given by DirectoryStack[].

ResetDirectory removes the last element from the directory stack, and makes the second-to-last element current.

And the page for DirectoryStack[] says:

Each call to SetDirectory prepends one element to the directory stack; each call to ResetDirectory drops one.

So it is not surprizing that DirectoryStack[] initially is a blank list. The call to SetDirectory adds to this list one element: previous working directory. To get the current working directory you should evaluate Directory[].

share|improve this answer

The exact code (I also happen to have a D partition:) runs fine on my computer (Win7, mma 8). The file is created in D:\, just the output of DirectoryStack is misleading. I don't really know, why it doesn't include D:\

You can check your current working directory using Directoy.


(* ==> "E:\\Projekti\\MD\\SCRIPTS\\mathematica\\FitSpectra" *)


(* ==> {"C:\\Users\\ajasja\\Documents"} *)


(* ==> "D:\\" *)

A := 5;

Export["A.wdx", A];


==> {"E:\\Projekti\\MD\\SCRIPTS\\mathematica\\FitSpectra", \


(* ==> "D:\\" *)
share|improve this answer

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.