Parse / Convert string - i give up

L

Lelle

sorry for crossposting im not sure i was in the right group

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
 
P

Patrice

I would do it the other way round. I would user Server.MapPath("/") to get
the physical location of my root and when trasversing I would just use the
name to of the encountered element to build the URL...

You may want also to put this outside of your web root and use a streaming
page...

Patrice
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top