Re: Want to use SqlFileStorage Class

  •  02-10-2008, 7:23 PM

    Re: Want to use SqlFileStorage Class

    Ok I think I solved it. I have the SQLFileStorage class in vb. Below is the CalcPath function and my changes in red. It seems to have solved the problem when you use a root other than "/"
     

    Private Function CalcPath(ByVal path As String, ByVal relpath As String) As String

    path = path.Replace("\\", "/")

    If Not (path.StartsWith("/")) Then

    path = CalcPath(VirtualRoot, path)

    End If

    If String.IsNullOrEmpty(relpath) Then

    Return path

    End If

    If (relpath.StartsWith("/")) Then

    If (relpath.IndexOf("..") <> -1) Then

    Throw (New Exception("Absolute path can't contain '..'"))

    End If

    If (relpath = "/") Then

    Return relpath

    End If

    Return relpath.TrimEnd("/")

    End If

    Dim str As String

    For Each str In relpath.Split("/\".ToCharArray())

    If (str = "") Then

    Continue For

    End If

    If (str = "..") Then

    Dim pos As Integer = -1

    If Not String.IsNullOrEmpty(path) Then

    pos = path.LastIndexOf("/", path.Length - 2)

    End If

    If (pos = -1) Then

    path = Nothing

    Else

    path = path.Substring(0, pos)

    End If

    Else

    If Not ("/" & str = path) Then

    path += "/" & str

    End If

    End If

    Next

    If (path = "") Then

    Return "/"

    End If

    Return path.Replace("//", "/")

    End Function

View Complete Thread