Solved

Help with exact string match

Posted on 2007-04-06
2
202 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 143

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

808 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