c# - How to detect OS my Asp.Net Core app is running on? -


i have asp.net core 1.0.0 app runs on both linux , windows. in app need upload files , save them in wwwroot subfolders. ihostingenvironment.webrootpath , specify subfolder. works fine on windows not on linux because of paths. window's \ of course not going work. how can detect whether app running on windows or linux controller , choose appropriate path delimiter?

rather this, should use path.combine generate directory names. example:

var root = env.webrootpath; var mydirectory = path.combine(root, "subdirectory"); 

Comments