Relative paths in C #

I need help with ways, please!

Basically, I have a project with the following folder structure:

Project (root directory which contains the .sln file etc.)
Project/MyProj (contains the code)
Project/MyProjTest (the test folder)
Project/TestResults

Now with this project, I need to have a shared folder in which I can store a bunch of files for use with the application without having to copy files to several locations, etc. What is the best way to do this? Ideally, I would like to have a folder like Project / ResourcesFolder, so that both the Code folder and the Test folder can access it. Now, if so, how can I call this folder from C #? I tried Application.StartupPath, Environment.GetCurrentDirectory, but they both just return the CURRENT folder, which is not what I want.

Thanks in advance.

+3
source share
4

.

+1

, , . - . "" " = ", " " = "", "". , .

, , EXE. , . Application.StartupPath, . .

, , .

+1

..one directory goes up. That is, from Project/MyProjTestyou can access Project/MyProjthrough ../MyProj.

0
source

Use Server.MapPath ("~") to get to the root folder of your application. From there you can get to where you need to.

0
source

Source: https://habr.com/ru/post/1742588/


All Articles