Service Fabric Application Root Directory

In my code I fail

if (!File.Exists(_configurationFileName)) {...}

In a direct window, I made a call Directory.GetCurrentDirectory()and pointed me to the work folder , and not to the code folder , which I would expect.

Directory.GetCurrentDirectory()
"C:\\SfDevCluster\\Data\\_App\\_Node_0\\My.Application.Type_App2\\work"

Thus, my configuration file, which is located next to the executable file, of course, was not found.

Now I wonder what the solution is.
Since I also want to continue working with the console application, I do not want to implement any kind of "hosting, if you change the current directory, ...".

Any recommendations? What about my .exe.config files (if I had, how would they be found)?

What is the reason that Service Fabric is setting the current directory to "work"? Is this some kind of security mechanism?

+4
4

,

<EntryPoint>
  <ExeHost>
    <Program>configui.exe</Program>
    <WorkingFolder>CodePackage</WorkingFolder>
  </ExeHost>
</EntryPoint>
+7

"" ", " , .

0

- , , . , , , .

string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
string filePath = Path.Combine(Path.GetDirectoryName(exePath), "myfilename.txt");
0

" " " " , , .

" ", , . wwwroot, ( ) .

> a > > >

0

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


All Articles