I have a WCF service that reads a file upon creation.
I added the file to my project, set it's Buid Action to Content and Copy to Output Directory to Copy always, and used the following to get the file path:
private const string MEDIA_PLAYER_FILENAME = "mediaPlayers.xml";
var mediaPlayerFilePath = Path.Combine(Environment.CurrentDirectory, MEDIA_PLAYER_FILENAME);
This works well when I self-host it In a Console app, but when it is being hosted in Windows Service, it fails because it tries to read it from C:\Windows\system32\mediaPlayers.xml
I guess Environment.CurrentDirectory
is not the one I should use. What should it be? or is there another approch to do this?