c# - Where do I put supplemental files in a Windows Service? -


ok, here's situation. have written windows service. testing "console" app has shown promising results.

unfortunately, can't figure out put file. have json data critical application. it's in file. i'd rather not go detail on that, know has in file,and it's critical. it's not config file, needed.

anyway, i've added file windows service project. problem is, can't quite figure out right code , settings use put file in right place when service gets installed.

this second windows service have ever written, , first 1 (years ago) didn't require supplemental files.

i wrote service in visual studio 2015, on windows 7. testing on local machine here @ office, go on production machine.

help, please? ideas should put file , how should reference in code?

i saw site said should use following:

system.io.directory.setcurrentdirectory(system.appdomain.currentdomain.basedirectory); 

but didn't seem when did this:

filepath = environment.currentdirectory + "\\myfile.ext" 

file paths have never been strong suit of mine in these instances.

any here appreciated.

i haven't tested this, see no reason why wouldn't work:

internal string filepath =      system.io.path.combine(       system.appdomain.currentdomain.basedi‌​rectory,        settings.default.jsonfile); 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -