Hi,

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

TIA

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

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.

My.Computer.FileSystem.GetName(filename)

Returns just the filename portion of the fully qualified file.

My.Computer.FileSystem.GetParentPath(filename)

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

profile.DOMAIN

and the second returns

C:\Users

Be a part of the DaniWeb community

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