Make my own error message in the statusbar

Hi,

At the line of code that I have marked with an arrow
it gives the actual error in the panel sbMess of a statusbar
but i want to catch the error and display my own text in the
panel of the statusbar?
How can I do that?

Greetings,

Peter Kiers
private void btnInsPmp_Click(object sender, EventArgs e)
        {
            try
            {
                if (System.IO.Directory.GetFiles("I:\\REPORT\\XML", "I*.xml").Length > 0)
                {
                    string[] wholefolder = System.IO.Directory.GetFiles("I:\\REPORT\\XML", "*", System.IO.SearchOption.AllDirectories);
                    foreach (string x in wholefolder)
                    {
                        System.IO.File.Copy(x, "\\XML" + System.IO.Path.GetFileName(x));
                    }
                }
            }
            catch (Exception err)
            {
                sbMess.Caption = (err.Message); <============================
            }
        }

Open in new window

LVL 1
Peter KiersOperatorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
sbMess.Caption = "My custom error message goes here";  //(err.Message); <============================
0
Peter KiersOperatorAuthor Commented:
OKe but then I get:
The variable 'err' is declared but never used

P.
0
AndyAinscowFreelance programmer / ConsultantCommented:
That is just a warning, the compiler realises you have a variable but don't use it in the code anywhere - check warnings and take appropriate action.  In this case just ignore it, you don't want to use the variable.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Peter KiersOperatorAuthor Commented:
Oke. thanks for the info.

Peter
0
AndyAinscowFreelance programmer / ConsultantCommented:
ps.
System.IO.File.Copy(x, "\\XML" + System.IO.Path.GetFileName(x));

Is that what you want?  It looks odd to me, check the results of the copying process.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.