0

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

2
  • 2
    By "root path" - do you mean "on the file system" (i.e. c:\mywebapp\files? or do you mean "the http path" (i.e. http://foo/bar/blap/blop/ )? Commented Jun 15, 2012 at 6:08
  • wait a minute, httplistener is supposed to listen to http requests - no paths are involved in that process. Do you mean the addresses the listener will listen to? that has nothing to do with Apache's(or IIS) root path. Commented Jun 15, 2012 at 6:09

1 Answer 1

1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.