Link to home
Start Free TrialLog in
Avatar of brettr
brettr

asked on

Help with exact string match

I'm looping through the folder appA and all of its subfolders.  Some of the folders are:

c:\dev\myapps\appA\bin\release
c:\dev\myapps\appA\source
c:\dev\myapps\appA\bin\debug
c:\dev\myapps\appA\obj\appAUI
c:\dev\myapps\appA\obj\appAUI\TempPE

I set a variable that will be used as a relative path for the appA folder
Root = "appA"

Inside the loop, I may be on this folder:
paramDirectoryPath = "c:\dev\myapps\appA\obj"

and I create the relative path on each iteration this way:

paramDirectoryPath.LastIndexOf(string.Concat("\\", Root))
which gives
"\appA\obj"

It creates a relative root path for all subfolders in the appA folder.

I run into a problem when
paramDirectoryPath = "c:\dev\myapps\appA\obj\appAUI"

The LastIndexOf() code will give
"appAUI" instead of "appA".

I need to somehow get an exact, case insensitive match.  IndexOf() doesn't do this.  What is a way that I can get around that?
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brettr
brettr

ASKER

Thanks.  I actually ended up restructuring how this works but that's not your fault.  :)