Best practise for using the IGeoProcessor Exist method

1647
0
01-31-2012 07:12 AM
DuncanHornby
MVP Notable Contributor
All,

I have developed some code that uses the IGeoProcessor object. It was bombing out when I was adding a Toolbox with an incorrect path. I realised my mistake and decided to add a bit of error trapping by using the Exist method to check if the toolbox exists before trying to add it to the GeoProcessor.

So my code looks like this:

Dim pGP As IGeoProcessor2
pGP = New GeoProcessor
If pGP.Exists("C:\temp\test.tbx", "Toolbox") Then
   pGP.AddToolbox("C:\temp\test.tbx")
End If


In the help it says:

Test the existence of a given parameter value (GPValue or catalog path) the type of the data is optional.


So my catalog path is obviously C:\temp\test.tbx but my data type is not optional I have to put something there. I tried Nothing and even a string that contains nothing or any text I like. So the line of code below is accepted and runs without error returning true (as the toolbox exists).

pGP.Exists("C:\temp\test.tbx", "Duncan is ace")


So what do all the developers have to say about this? What should I put there for the non-optional parameter? I could just put Nothing or maybe I should put something sensible, but the Help gives NO help about what possible value I should put there, it says it should be a variant that represents pDataType. There is an interface call IGPDataType but as I can put anything there I find myself wondering what should really go there?

Duncan
0 Kudos
0 Replies