4

I have a problem that I am trying to work on. My Folder structure is like this.

  • Application(MainDirectory)
  • AppData( Secondary directory where files are Design.m, Layout.m, and Evaluation.m)
  • Data(Another directory where datafiles are excel cheets, csv sheets, etc)

The design.m file calls for an listTabValues = Import[FileNameJoin[{DirectoryName[NotebookDirectory[], 1], "data", "VariableNames.xlsx"}]] to access data in the files of the Data folder. I have a notebook in the Application(Main Directory) where I do Get[FileNameJoin[{NotebookDirectory[], "AppData", "Design.m"}]] to get the contents of the Design.m file. The problem is when I evaluate in this manner, the NotebookDirectory[] is set to the Application(Main Directory) and the design takes the same value and not the AppData directory as the NotebookDirectory where the Design.m files resides and the data access fails. Any way to wok around this?

Anuk
  • 452
  • 2
  • 9
  • 3
    Don't make your project notebook-centric then. Put your project layout into e.g. $UserBaseDirectory/Applications, and you can use $InputFileName to record the absolute location of your main package at load-time (see this answer for details). Locate your other resources by fixed relative paths, relative to the main package. This is how such things are usually done. Then, in notebook, you will simply have to call Needs[your-package]. – Leonid Shifrin Feb 12 '13 at 11:50
  • 2
    See also this answer for another example of what I mean. – Leonid Shifrin Feb 12 '13 at 11:52

0 Answers0