Reverentjim kindly gave me this code the other day that worked well. There are two more things i am trying to do but cant get my head around it.

1) I want to be able to extract the text after the second \ and before the period
e.g. profile

2) if exists, I want to change the text to lower after the period

e.g. domain


dim str as String = "C:\Users\profile.DOMAIN"str = str.Substring(0, 1).ToLower & str.Substring(1)

Recommended Answers

Is C:\Users\ constant? or it will change?

Jump to Post

use string.Contains method...

Jump to Post

All 5 Replies

Is C:\Users\ constant? or it will change?

use string.Contains method...

try regular expression better and sophisticated way

Hey, you could use something like this:

Dim path as string = "C:\Users\profile.DOMAIN"
Dim Str as string() = path.substring(path.lastidexof("\")+1).split(".")

with that you get Str with 2 values, the first one Str(0) should be profile, the second one Str(1) DOMAIN, now just use them as you please.


Returns just the filename portion of the fully qualified file.


Returns the path portion. For filename = "C:\Users\profile.DOMAIN", the first returns


and the second returns


Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.