Relative Path with virtual subdirectory

1

Good afternoon,

I've been searching the internet for solutions to my current problem with paths, but I can not find them.

Imagine that I have the following links:

  

www.site/Arquivos/Uploads/imagem.png

     

www.sitedev / Client / Files / Uploads / image.png

In this case, in the first link I always get the path of the image back-end without using HttpContext.Current.Server.MapPath , but when I try the same with the second link, it ignores the Client subfolder. In case, I pass as parameter "~ / Files / Uploads / image.png".

This subfolder exists in a development environment for different applications to be hosted.

Is there a method that can get both cases, or even more subdirectories before the application is found?

Editing

One of the cases that I'm having problems with is the following code:

// Os valores das variáveis são:
//
// ultimoDigitoDoId = "4";
// Configuracoes.DiretorioUploadEmpresa = "~/Arquivos/uploads/empresas/"

var pasta = HttpContext.Current.Server.MapPath(String.Format("{0}{1}\{2}",
    Configuracoes.DiretorioUploadEmpresa, 
    ultimoDigitoDoId, 
    "Imagens"));

if (!Directory.Exists(pasta))
    Directory.CreateDirectory(pasta)

When the folder is created and the files are saved in it, it is created outside the 'Client' context, the one I showed above in the two link examples

    
asked by anonymous 22.01.2016 / 14:52

1 answer

0

You have no problem with your code. It's just a matter of the logic involved:

var pasta = HttpContext.Current.Server.MapPath(String.Format("{0}\{1}{2}\{3}",
    "Cliente",
    Configuracoes.DiretorioUploadEmpresa, 
    ultimoDigitoDoId, 
    "Imagens"));
    
22.01.2016 / 17:12