I am developing an application .NET Core (dotnet) in C# that must run on Windows 10, Linux AND in the Linux subsystem that can be installed in Windows 10.
The problem is that the application must stored files in a common location to let other application use they. That is, others applications (that are clients) must resolved the same path as this application does. So, the same code must be added in all of the clients to know where the files are storage.
I searched a lot and I found this solution:
Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData));
This returns me on Windows:
C:\ProgramData
And on Linux:
/usr/share
I like this solution but the problem here is that when the program is running in a Linux subsystem, I want to use a path that can be acceded from applications running on Windows natively.
I know that Windows is mounted in /mnt/c/ in the Linux subsystem but y dont want to have hardcoded paths.
Is there any way to have programatically (running on Linux subsystem) a path in the Windows host? That is, if the program run on Linux natively the path that returns is /usr/share BUT if it is a subsystem, the path that returns is /mnt/c/ProgramData (or something like that).
Thanks!