Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set relative paths in app.config file?

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

like image 455
Shekhar Avatar asked Nov 05 '22 16:11

Shekhar


1 Answers

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?

like image 143
Asad Avatar answered Nov 14 '22 15:11

Asad