i give up....parse string

  • Thread starter Thread starter Lelle
  • Start date Start date
L

Lelle

hello i want to parse/rplace/construct wahtever a string i get

i read with directoryinfo out the root off my webapplikation
Dim dirInfo As New DirectoryInfo(Server.MapPath(""))

c:\inetpub\wwwroot\TEST

i store this in a variable called physicalbasepath


i list all folders in a datagrid and adds a buttoncollmn that executes using
this which steps me one level into the filesystem
Dim dirinfo As New DirectoryInfo(Server.MapPath(e.Item.Cells(1).Text)) '
where cell1 contains the full path of that dir i wanna go in to

i store this in a variable called subphysicalbasepath

i now have c:\inetpub\wwwroot\TEST and c:\inetpub\wwwroot\TEST\subfolder1
' here we can get deep in so we must keep all from TEST\.....\and down

i wanna turn this into http://server.domain.com/test/subfolder1 - this must
be dynamic so i can use on any server and the folders can have any name

i gets the urlpath using this

Dim basepath As String = Request.Url.GetLeftPart(UriPartial.Authority) +
ResolveUrl(Request.ApplicationPath) which gives me
http://server.domain.com/test

my though was to replace c:\inetpub\wwwroot\TEST\subfolder1 with basepath so
it looks like this http://server.domain.com/test\subfolder1 then i can easy
switch the \ to a /

i can only accomplish this if i use this - replacing char with string

Dim virtualpath1 As String =
dirinfo.FullName.Replace("c:\inetpub\wwwroot\TEST", basepath) this gives
http://server.domain.com/test/\subfolder1 which is what i want but not
dynamic enough

It wont work use this replace string to string

Dim virtualpath1 As String =
dirinfo.FullName.Replace(subphysicalbasepath,basepath) this gives
c:\inetpub\wwwroot\TEST\subfolder1
 
:) too long introduction...

try to use Path and its static methods....Combine() par example...

Cheers,
Daniel
 
Back
Top