Solved

Help with exact string match

Posted on 2007-04-06
2
199 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
Comment Utility
paramDirectoryPath.ToUpper().IndexOf( string.Concat("\\", Root).ToUpper())
0
 

Author Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 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

12 Experts available now in Live!

Get 1:1 Help Now