Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

server.mappath and trimming

Status
Not open for further replies.

Shift838

IS-IT--Management
Jan 27, 2003
987
US
I have the following code and I want it to retrieve the current directory only.. so if the directory is:

d:\inetpub\
it will return only:

LALALA

shouldn't this do it:

Dim strsubdomain As String = Server.MapPath(".")
Dim newpath As String

lblstatus1.Text = strsubdomain
newpath = Microsoft.VisualBasic.Right(lblstatus1.Text, 24)

lblstatus2.Text = newpath

Would this not trim the first 24 characters of the directory structure starting at d:?

according to the msdn it should, but I cannot get it to work, it actually shows the first 24 characters and trims the rest.
 
You should really try not to use the VisualBasic class if you can help it, and use the .NET framework instead. There are multiple ways you could do it it the framework and here's one of them:
Code:
        Dim s As String = "d:\inetpub\[URL unfurl="true"]wwwroot\webx\LALALA"[/URL]
        Dim s1 As String = s.Substring((s.LastIndexOf("\") + 1), s.Length - (s.LastIndexOf("\") + 1))


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
ca8msm,

ahh.. ok. I got it thanks. one other thing, since I am so new to asp.net and vb.net do you know any good refererence books I could obtain?
 
There have been quite a few posts on these forums about good books so you could try searching for these (although the search engine isn't particulary good at the moment!). Also, try looking at sites such as:


as these contain some very useful articles and tutorials.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
yea I noticed the search engine was not doing well so I posted it here. I did see that MSDN has a reference collection of 7 volumes and it looks pretty good, has anyone seen it? I used the vb 6 reference guides and it was very good.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top