Domanda

I am using HttpListener Class to produce a local web server. But by default, HttpListener Class will read the path which saves HttpListener exe file.

If I want to set a different path as server root path, just like Apache can choose a root path, how to do it with HttpListener?

I have read the HttpListener document, but there is no method for doing this.

Thanks

Water Lin

È stato utile?

Soluzione

But by default, HttpListener Class will read the path which saves HttpListener exe file. "

HttpListener has very little interest in local paths at all. Do you mean "my own code is defaulting to the working directory"? If so, this could simply just a case of

Directory.SetCurrentDirectory(rootDirectory);

Although actually, frankly I'd just expect this to be done by keeping a string rootDirectory (or maybe a DirectoryInfo) kicking around, and working relative to that.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top