Dmitry Volkov
Dmitry Volkov

Reputation: 1337

Path to LocalAppData in ASP.Net Core application

I have an ASP.Net Core application, and for the current purposes I've got to use LocalAppData.

Usually I would write Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), but unfortunately it's not working with ASP.Net Core.

Could anyone help me with this?

UPDATE

Thanks to Adem Caglin, I've found the solution.

The code I use:

Environment.GetEnvironmentVariable( RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "LocalAppData" : "Home");

Upvotes: 22

Views: 13186

Answers (2)

Filipe Carneiro
Filipe Carneiro

Reputation: 528

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

Upvotes: 6

adem caglin
adem caglin

Reputation: 24073

Try this:

Environment.GetEnvironmentVariable("LocalAppData");

ps: tested on windows

Upvotes: 17

Related Questions