Author Topic: best practice when using dialog result OK  (Read 6105 times)

0 Members and 1 Guest are viewing this topic.

Ken Alexander

  • Newt
  • Posts: 61
Re: best practice when using dialog result OK
« Reply #15 on: April 23, 2010, 11:36:56 AM »
Oh, and as another point, you're using a MessageBox in the inner "catch" statement.  That's OK, but it forces the user to hit OK to continue.  Imagine what would happen if the user selected 100 files, and they all start erroring out - the user might have to hit "OK" 100 times before the routine finally exits.

Another point to go along with this is allowing the user to cancel out of the copy.  Depending on the number and size of files, this could take a while.  You might look at copying files/directories using My.Computer.FileSystem namespace.  My.Computer.FileSystem.CopyFile gives options for this.
Ken Alexander

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: best practice when using dialog result OK
« Reply #16 on: April 23, 2010, 11:38:43 AM »
Don't worry about multiple exit points in .NET... it's got one of them managed stacks  :roll:

Glenn R

  • Guest
Re: best practice when using dialog result OK
« Reply #17 on: April 23, 2010, 11:48:36 AM »
You could also use Path.Combine(string1, string2) as well...

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: best practice when using dialog result OK
« Reply #18 on: April 23, 2010, 11:54:24 AM »
Thanks eveyone, I will look into the Path options
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Bobby C. Jones

  • Swamp Rat
  • Posts: 516
  • Cry havoc and let loose the dogs of war.
Re: best practice when using dialog result OK
« Reply #19 on: April 23, 2010, 01:27:19 PM »
I recommend using it with wanton abandon :-)

Me too.  But I'm also a huge fan of jump statements.  I do this all the time.

Code: [Select]
   static void Main(string[] args)
    {
      int i = 0;
      loop_begin:
        if (i == 10)
          goto exit;

        Console.WriteLine(i++);
      goto loop_begin;

      exit:
      Console.ReadKey();
    }



:)
Bobby C. Jones

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: best practice when using dialog result OK
« Reply #20 on: April 23, 2010, 04:21:52 PM »
 :lmao: :lmao: :lmao:
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)