Get Host File on my windows phone

58 Views Asked by At

I’m developing an UWP app for Windows 10 phone. The client request is to be able to get the HttpClient BaseAddress (Services address) from a local file located on the Host File like on desktop apps (C:\Windows\System32\drivers\etc\hosts). This is because they need to use the app on different local networks and they want to be able to change the URL manually from the file.

Any ideas? I didn’t find information about it. Basically what I need is to manually write an address in a file to be read by my app without allowing the user interact with the to file.

1

There are 1 best solutions below

0
Martin Zikmund On

I see two conflicting requests in your question - being able to manually write address in a file while at the same time without allowing the user to interact with the file.

If you store such configuration anywhere in the file system, where it can be manually written to, you cannot prevent the user to do the same. You could store the file in the applications ApplicationData.Current.LocalFolder which is more secure (although a crafty user can still find a way to edit the files stored there) but you would lose the ability to make manual edits, so your app would have to contain an area that would allow the user to edit the configuration.

In any case - ability to manually edit means user can interact with the file as well.

My approach would be to ask the administrators to create a HTTP endpoint, that would always return the configuration information you require on any given network, which your app would download on startup to reconfigure itself.