Check if file exists

1041
2
Jump to solution
11-06-2012 03:03 PM
StanStas
New Contributor
Hello,

have 2 parts question. I've file path loaded into textbox by user... I don't know what data type it is (File, mdb or shapefile.. vector or raster...).

1. I'd like to check if that file path exists. I can use System.IO.File.Exists, but it works only for shapefiles.
2. I'd like to add that file into ArcMap if it is possible. I know how to do this with File geodatabase, but again - I don't know what data type it is http://forums.arcgis.com/threads/67004-Get-Data-Type-from-Path?highlight=path

thanks
0 Kudos
1 Solution

Accepted Solutions
BruceNielsen
Occasional Contributor III
1. Have you tried the Exists geoprocessing tool?
2. Take a look at some of the 'Open...' methods available in the GPUtilities class

View solution in original post

0 Kudos
2 Replies
BruceNielsen
Occasional Contributor III
1. Have you tried the Exists geoprocessing tool?
2. Take a look at some of the 'Open...' methods available in the GPUtilities class
0 Kudos
StanStas
New Contributor
So, problems are solved, thanks a lot Bruce!

1. gp.Exists works nicely

Dim dt As Object = ""
Dim bExists As Boolean = gp.Exists(path, dt)


2. GPUtilities class has AddToMap function

    
Dim pGPUtil As IGPUtilities
Dim pDataElement As IDataElement

pGPUtil = New GPUtilities

' Add a rasterdataset to the map
pDataElement = New DERasterDataset
pDataElement.CatalogPath = path
pGPUtil.AddToMap(pDataElement, "", False, Nothing)

' Add a featureclass to the map
pDataElement = New DEFeatureClass
pDataElement.CatalogPath = path
pGPUtil.AddToMap(pDataElement, "", False, Nothing)
0 Kudos