473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Parse / Convert string - i give up

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,basep ath) this gives
c:\inetpub\wwwroot\TEST\subfolder1

Nov 19 '05 #1
1 1085
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

--

"Lelle" <sv****@hotmail.com> a écrit dans le message de
news:42********@news.wineasy.se...
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,basep ath) this gives
c:\inetpub\wwwroot\TEST\subfolder1


Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: | last post by:
Hi, I need to read a big CSV file, where different fields should be converted to different types, such as int, double, datetime, SqlMoney, etc. I have an array, which describes the fields and...
3
by: Jon Davis | last post by:
The date string: "Thu, 17 Jul 2003 12:35:18 PST" The problem: // this fails on PST DateTime myDate = DateTime.Parse("Thu, 17 Jul 2003 12:35:18 PST"); Help? Jon
19
by: linzhenhua1205 | last post by:
I want to parse a string like C program parse the command line into argc & argv. I hope don't use the array the allocate a fix memory first, and don't use the memory allocate function like malloc....
3
by: Patrick De Ridder | last post by:
s is a string f is a single precision float f = float.Parse(s);// (a) f = Convert.ToSingle(s);// (b) Is (a) just as good as (b)? If one should be used, not the other, please give the reason....
14
by: Jon Davis | last post by:
I have put my users through so much crap with this bug it is an absolute shame. I have a product that reads/writes RSS 2.0 documents, among other things. The RSS 2.0 spec mandates an en-US style...
10
by: Flip | last post by:
I know the int.Parse("123") will result in an int of 123, but what happens with a null? I believe it give a null exception (seems like I get either NullArgumentException or ArgumentNullException...
2
by: John Salerno | last post by:
Is there any difference (performance-wise or otherwise) between the Parse method and the methods of the Convert class when dealing with a string? Int32.Parse(string); or ...
7
by: sara | last post by:
Hi to all i have string y; int x=int.parse(y); when i run the application this exeption is trewn /////////////////////////////////////// Description: An unhandled exception occurred during the...
4
by: tshad | last post by:
Is there any difference between convert.ToDateTime and System.DateTime.Parse? I am using them both and they seem the same. Is one better to use than another? Thanks, Tom
4
by: Peter Proost | last post by:
Hi group, it's been a long time since the last time I've been here but I have a question. I'm working with timespan.parse for calculating a duration, I have to add strings which are in the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.