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[] 


  "C:\\Users\\user\\Documents"

  In[8]:= DirectoryStack[]

  Out[8]= {}

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

  Out[10]= "D:\\"

  A:=5;

  Export["A.wdx", A];

  In[13]:= DirectoryStack[] 

  {"C:\\Users\\user\\Documents"}
share|improve this question
1  
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? –  Problemaniac May 2 '12 at 21:43
1  
As reality check, have a look if and where "A.wdx" is in fact saved...? –  Yves Klett May 3 '12 at 9:43
add comment

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
add comment

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.

ResetDirectory[]

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

DirectoryStack[]

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

SetDirectory["D:\\"]

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

A := 5;

Export["A.wdx", A];

DirectoryStack[]

(*
==> {"E:\\Projekti\\MD\\SCRIPTS\\mathematica\\FitSpectra", \
"C:\\Users\\ajasja\\Documents"}
*)

Directory[]

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

Your Answer

 
discard

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.