views:

50

answers:

1

My website is in the root directory, which is /www.lebmotor.com/web/content/.

I am using this:

Dim appPath As String = HttpContext.Current.Request.ApplicationPath  
Dim directory As String = appPath & "/upload/" & Left(TableName, 2) & "/"  

to get the path and it's working very well.

But when I create a new sub-folder and copy some pages from the root directory into the sub-folder, my images are not displayed because the path has changed.

This is the link from the page in the root directory:

http://www.lebmotor.com/upload/VE/TN/6/VEListing-66-Photo1.jpg?ts=9/4/2010%201:45:17%20AM

and this is the link from the page in the sub-folder:

http://www.lebmotor.com/ar/upload/VE/TN/6/VEListing-66-Photo1.jpg?ts=9/4/2010%201:45:17%20AM

So how can I make the link in the sub folder like this:

http://www.lebmotor.com/upload/VE/TN/6/VEListing-66-Photo1.jpg?ts=9/4/2010%201:45:17%20AM


Let me explain more about this. First, I have two directories and both of them have been set as application directories, as you can see here in the photo:

The /ar sub-folder is an application and it's a copy of the original one in the Content directory.

In the ar/App_code there is a class with the name MGImages.vp, and course it's a copy of the original one in Content/App_code. This class' job is to display photos from the Upload sub folder.

This is the code which will save the path of the photo:

Dim appPath As String = HttpContext.Current.Request.ApplicationPath  
Dim directory As String = appPath & "/upload/" & Left(TableName, 2) & "/"  
If ImageType.ToUpper = "TN" Then  
    directory += "TN/"  
ElseIf ImageType.ToUpper = "LG" Then  
    directory += "LG/"  
Else  
    directory += "OT/"  
End If  

This class is working very well in the Content directory because this will give me the right path:

http://www.lebmotor.com/upload/VE/TN/6/VEListing-66-Photo1.jpg?ts=9/4/2010%201:45:17%20AM

All photos should be saved in the Content/Upload folder for both directories' Content/ar

But in the ar directory it will give me the wrong path:

http://www.lebmotor.com/ar/upload/VE/TN/6/VEListing-66-Photo1.jpg?ts=9/4/2010%201:45:17%20AM

Where the goal is to make the path like this one:

http://www.lebmotor.com/upload/VE/TN/6/VEListing-66-Photo1.jpg?ts=9/4/2010%201:45:17%20AM

I want it to display the photos from Content/upload, not from the content/ar/upload.

A: 

When you first construct the image path, you can remove the ar path:

Dim directory As String = appPath & "/upload/" & Left(TableName, 2) & "/" 
directory = directory.Replace("/ar/", "")
Oded
oooooh my god!!!why didn't I think about such easy thing ?????this answer make the The biggest fool in the whole world!!!Mr.Oded thank you so muchthank you so much,you are the best.some people think in the hard way while smart people select the easiest and the most effective ways.thanks again.
HAJJAJ