1
Good afternoon,
I’ve been searching the internet for solutions to this my current problem with paths, but I can’t find.
Imagine that I have the following links:
www.site/Files/Uploads/image.png
www.sitedev/Client/Files/Uploads/image.png
In this case, in the first link I can always pick up the image path by back-end using HttpContext.Current.Server.MapPath
, but when I try the same with the second link, it ignores the Client subfolder. In this case, I pass as parameter "~/Files/Uploads/image.png".
This subfolder exists in a development environment for hosting different applications.
Is there any method that can take both cases, or even with more subdirectories before where the application is?
Editing
One of the cases I’m having trouble with is the code to follow:
// 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 context 'Client', the one I showed above in the two link examples
Show how you’re using.
– Maniero
You have a Clientecontroller?
– Andre Mesquita
We need a sample of the code that performs the mapping.
Server.MapPath
is an option, but there are other.– Leonel Sanches da Silva
@Andremesquita No, folder and images are saved with the code I entered in the edit
– Striter Alfa
@Gypsy omorrisonmendez posted a sample
– Striter Alfa
@Bigown I made an issue in my post. I believe that the main problem is the creation of the folder, because with the same folder created (in wrong place), it saves the images inside it using the same variable as reference.
– Striter Alfa
@striterAlfa you have a controller called Clientecontroller? If there is, when you try to write the file in that folder, it is not being called an action named Files?
– Andre Mesquita
@Andremesquita looked up the name Clientecontroller in Solution and got no results. The problem, as I commented in the Gypsy reply below, is that "Client" is not a fixed directory, it varies according to the IIS in which the application is running. There are homologation environments that he calls "Homolog" and development that he calls "Dev". I can get this information from javascript using window.baseUrl, but I can’t get it from the backend
– Striter Alfa