Select to view content in your preferred language

Using Exists Method from Geoprocessor object - C#

652
3
05-25-2010 11:55 AM
Jose_LuisGarcinuno-Oporto
Occasional Contributor
Hello All, I am re writting a  VB6 apps to C#, I reach the point where I need to use Exists method but I had not find the right way to do it, any help it would be great.

This is my current vb6 code and it's works.

Dim Site As String
Site = GP.Exists("\\cakotrm3\Users\AHCP_Roads\Road Assessment\CA_RAD.gdb\sites", "")
if Site = true then
do something
End if

this is my current C# code (no working).
Exists(object input value, ref object data type)
if GP.Exists(@"\\cakotrm3\\Users\AHCP_Roads\Road Assessment\CA_RAD.gdb\site",object);
I got a message "No everload for 'Exists' methods takes '1' argument". I know that is related with the second Exists method argument
0 Kudos
3 Replies
KirkKuykendall
Deactivated User
try adding "ref"

if GP.Exists(@"\\cakotrm3\\Users\AHCP_Roads\Road Assessment\CA_RAD.gdb\site",ref object)
     do_something();
0 Kudos
ReidWatkins
Deactivated User
Does anyone have a solution for how to use gp.Exists in C#?  Kirk's suggestion above doesn't seem to compile.  Since the second parameter is documented as optional, I tried using null but that doesn't compile either.
0 Kudos
AlexanderGray
Honored Contributor
Usually to pass a null by ref in C# you have to declare a variable as object and initialize it to type.missing.  If you passed an empty string in vb.net, I would think you need to pass the empty string by ref in C#, "ref string.empty".
0 Kudos