c# - Relative filepath with HttpWebRequest object -


I am trying to create unittests that can be shared between my development team so that all the paths in the project are related Need to be .

This is bothering me with the HttpWebRequest class, I want to serve the static test data from the file in the local file system.

I want to do something like this:

  file: ///./TestData /test.html  

but that's just Creates C: \ TestData \ test.html and a DirectoryNotFoundException

The code for HttpWebRequest looks like this:

  var request = HttpWebRequest.Create (uri); Var response = request GetResponse (); Var reactionflow = new streamerdidder (feedback. Gatesresponsescrew ()); Return Revive Reed to End ();  

How can I explain C # to solve a relative path without breaking Uri syntax?

Greetings Daniel

Do you have server compared to any assembly in your project Is the relative path of the file trying? If so, you can build a non-relative URL based on the path of an assemblies and return the caller.

For example:

  var basepath = path. Gate directory name (typef (MyType) assembly. Location); Var full path = path.combin (basepath, @ "testdata \ testma"); New Uri (full path) returned;  

Comments