Solved

Help with exact string match

Posted on 2007-04-06
2
201 Views
Last Modified: 2013-11-07
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?
0
Comment
Question by:brettr
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18868054
paramDirectoryPath.ToUpper().IndexOf( string.Concat("\\", Root).ToUpper())
0
 

Author Comment

by:brettr
ID: 18868125
Thanks.  I actually ended up restructuring how this works but that's not your fault.  :)
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now