I am trying to share a folder between two websites that are on the same machine and configured with the same IIS managements screens.
I have tried the solutions in the other questions, but I could not get them to work.
I have tried the following:
I created softlinks like this:
mklink /d C:\Site2\Images C:\Site1\Images
I used a softlink rather than a hardlink because the rd command will just delete the softlink rather than deleting the files in the folder. Then I can redeploy my site without worrying about the images being deleting.
I suspect it is for security reasons that the folder cannot be shared between the sites.
I also tried to make the folder like this:
mklink /j C:\Site2\Images C:\Site1\Images
I also tried using virtual directory configuration. That did not work either. I suspect it because I am trying to access the folders using VB code rather than by URL.
This is what the code looks like:
Public Shared Function Ck4Image(ByVal SubDir As String) As String
Dim countfiles As String = ""
Dim ckdir As String = HttpContext.Current.Server.MapPath("~/Images/") + Trim(SubDir) + "/" ' Set the path.
Dim MyName = Dir(ckdir, vbDirectory) ' Retrieve the first entry.
If MyName = "" Then
Ck4Image = ""
Exit Function
End If
countfiles += SubDir & "|"
For Each afile As FileInfo In New DirectoryInfo(ckdir).GetFiles("*.jpg")
countfiles += afile.Name & "|"
Next
Ck4Image = countfiles
End Function
Here are my questions:
What is the tilde syntax in the MapPath function? It is not in the documentation that I read.
How can I achieve my goal of sharing the same folder between Site1 and Site2?
Note: I listed this on stack rather than server fault because I suspect it is a problem in my code that is preventing virtual directories from working.