C # Get url from local directory

Here is my program: I upload the image (Stream, FileInfo or whatever) to the server in this virtual directory: "C: \ _ Resources \ Assets"

But then I want the server to return the URL of this image in order to display it in the tag, i.e. " http: //localhost/Trunk/Assets/image.jpeg "

In fact, I'm trying to do the opposite of the Server.MapPath method.

How do i get this?

Thanks.

+3
source share
3 answers

url = "\\" + Environment.MachineName + Path.GetFullPath (document.FileName) .ToString (). Split (':') [1];

+2

"C: _Resources" "/Trunk"? , .

+1
string file = "\\\\" + someServer + "\\" + someFile;
file = file.Replace(":\\","$\\");

And, if you do not want to use these characters to exit the threshold ...

string file = @"\\" + someServer + @"\" + someFile;
file = file.Replace(@":\",@"$\");
0
source

Source: https://habr.com/ru/post/1709688/


All Articles