6

I am working on a project in which I have many text and xml files. I read those from my program at runtime.

I have kept paths to those files in app.config file, but all the paths are absolute paths like "C:\my_project\help_files\rejectList.txt" .

If I keep only "\help_files\rejectList.txt" path, program throws filenotfound exception.

Can anyone please tell me how to set relative paths in C# applications? 

I would like to set something like "$root\help_files\rejectList.txt" and at runtime $root should resolve to actual path.

Is there any way in .net to set paths like this?

Also, I have one more question. I have some dll's also that are needed for my project. Where do people usually keep dll's? In same folder as that of the exe file or should we create one folder called "lib" and put dll's there?

Thanks and Regards, Shekhar

Shekhar
  • 11,438
  • 36
  • 130
  • 186

1 Answers1

3

answer 1:, check Path Class

answer2: keep your dll's in output directory of projects. debug / release

see below

Optimizing Visual Studio solution build - where to put DLL files?

Community
  • 1
  • 1
Asad
  • 21,468
  • 17
  • 69
  • 94
  • 1
    @Asad, Thanks for quick reply. I saw the "Path class" information. If I use Path class, then I have to programatically join path given in app.config with current directory path. I will recommend something that will work from config file only. Similar to the way in which we specify paths in ant build files. First we specify root folder variable & then use that variable itself in other paths. Can we do something like that in C#? – Shekhar Feb 22 '10 at 07:27