Book a Demo

Author Topic: Determine if a Package exists in a Collection  (Read 4242 times)

jeffc030

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Determine if a Package exists in a Collection
« on: February 08, 2006, 10:36:33 am »
It seems that Models.GetByName throws an exception if the Name isn't present in the Collection.  I have seen Package.GetByName return if the Name is not present in the Collection.  What should I expect?  Is there an easier way to determine whether or not a Package exists in a Collection?  I am trying to create packages by breaking up a path, and not recreating if it already exists.

Thanks,

-Jeff

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Determine if a Package exists in a Collection
« Reply #1 on: February 08, 2006, 01:15:33 pm »
I too seem to get varying results here. I don't know if the behavior is different between the various collections, or if my memory of what's happening is faulty (either is possible).

A safe way is to trap for the exception, but still test for a null result. Given that you are working through an OLE interface (and possibly a Net Interop layer) this should not seriously impact your perceived performance.
No, you can't have it!