How to overcome error - Control cannot fall through one case label to another in a switch?

I'm trying to make a switch based on a folder path selected and if its 1.) blank - then warn the user if its not blank check to see if they selected a root folder 2.) I:\proj - warn that its too large.  I also want to add another root folder 3.) G:\pj where it would warn that is also too large!

The highlight is on case case (@"I:\proj"):

How may I rewrite the following to account for that and not get the error and include the other G:\pj folder?  I'm new to C# sharp so please be patient with me.  Thank you in advance!
string sPath;
            sPath = txtPath.Text;

            switch (sPath)
            {
                case "":
            
                MessageBox.Show("You have not selected a folder.  Please click 'Browse' to continue.");
                break;

                case (@"I:\proj"):
                MessageBox.Show("Folder too large to search.");

            }

Open in new window

LVL 1
stephenlecomptejrAsked:
Who is Participating?
 
SriVaddadiConnect With a Mentor Commented:
You can even say

case @"I:\proj":
            case @"I:\data":
            case @"G:\pj":
                MessageBox.Show("Folder too large to search."); break;
0
 
SriVaddadiCommented:
case @"I:\proj":
                MessageBox.Show("Folder too large to search."); break

0
 
SriVaddadiCommented:
case @"I:\proj":
                MessageBox.Show("Folder too large to search."); break;
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
stephenlecomptejrAuthor Commented:
Ok so that worked for me but how about other folders besides I:\proj?
Do I have to do?

case @"I:\data":
                MessageBox.Show("Folder too large to search."); break;

case @"G:\pj":
                MessageBox.Show("Folder too large to search."); break;

case @"I:\proj":
                MessageBox.Show("Folder too large to search."); break;

Can't I do something like:

case @"I:\proj", @"I:\data", @"G:\pj":
                MessageBox.Show("Folder too large to search."); break;

When I try I get invalid expression term ',' syntax error expected ':'
0
 
SriVaddadiCommented:
What are the other cases? if you have covered all other cases you can use

            default:
                MessageBox.Show("Folder too large to search."); break;    
0
 
stephenlecomptejrAuthor Commented:
Thank you greatly!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.