Select to view content in your preferred language

GxDialog doesn't always ask about replacing object

958
7
Jump to solution
08-07-2012 11:05 AM
KenBuja
MVP Esteemed Contributor
In my code, I'm using the following code to save a feature class

Dim pFCFilter As New ESRI.ArcGIS.Catalog.GxFilterFeatureClasses Dim pGxDialog As New ESRI.ArcGIS.CatalogUI.GxDialog  pGxDialog.Title = "Save feature class" pGxDialog.Name = "" pGxDialog.ObjectFilter = pFCFilter  If Not pGxDialog.DoModalSave(My.ArcMap.Application.hWnd) Then Exit Sub


When I select a feature class that already exists in a file or personal geodatabase, I'll get the expected "The object named "X" already exists. Do you wish to replace it?" However, when I select a shapefile that already exists, I don't get that message. Why would I get this inconsistent behavior?
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
This had been submitted as a bug: #NIM083649  IGxDialog:: DoModalSave() with GxFilterFeatureClasses does not always ask user for permission to overwrite when an existing shapefile is chosen. This issue occurs in both 10.0 and 10.1. Esri Support also said that "GxFilterFeatureClasses should work for featureClasses in the mdb and fdb, as well as the shapefiles."

I still don't know what that code works properly in another application. In subsequent testing, I found that other filters, such as  GxFilterPolygonFeatureClasses or GxFilterPointFeatureClasses, also don't ask for permission to overwrite files for shapefiles or geodatabase feature classes.

View solution in original post

0 Kudos
7 Replies
NeilClemmons
Honored Contributor
I would expect the GxFilterFeatureClasses class to filter any type of feature class but ESRI probably had geodatabase feature classes in mind when they implemented it.  It probably isn't appending the .shp extension onto the class name in order to check for the existing feature class.  Do you get the correct behavior when you use the GxFilterShapefiles class?
0 Kudos
KenBuja
MVP Esteemed Contributor
When I change it to GxFilterShapefiles, I'll get the replacement warning message. However, in another application using the same code (with GxFilterFeatureClasses), I get the warning for both shapefiles and feature classes in geodatabases.
0 Kudos
NeilClemmons
Honored Contributor
I'm not sure why it would work in one app but not another.  Just to rule out the obvious, have you double-checked to make sure it's the exact same code in both apps?  Are you trying to save to the same directory on the same computer with both apps and getting a warning from one but not the other?  It might be a permissions issue, and OS setting or something similar if you're running the two apps on different systems or as different users.
0 Kudos
KenBuja
MVP Esteemed Contributor
The first thing I did was check whether the code in the two applications was the same. And I'm testing them out on the same workspaces, so I am stumped as to why they're performing differently.
0 Kudos
NeilClemmons
Honored Contributor
When you specify the shapefile name are you typing it in or selecting the existing object displayed in the dialog?  Do you get different behavior depending on which way you do it?  Also, check the IGxDialog.ReplacingObject property to see if it's being set correctly.  If it is, then you can work around the problem by implementing your own warning message.  I really can't see why it work in one app but not the other either.
0 Kudos
KenBuja
MVP Esteemed Contributor
I'm getting this when I select the object via mouse. But typing in the name with or without ".shp" gives me the same result. I've checked the ReplacingObject property and it's not being set to true. It gets set to true when I select an existing feature class in a geodatabase.
0 Kudos
KenBuja
MVP Esteemed Contributor
This had been submitted as a bug: #NIM083649  IGxDialog:: DoModalSave() with GxFilterFeatureClasses does not always ask user for permission to overwrite when an existing shapefile is chosen. This issue occurs in both 10.0 and 10.1. Esri Support also said that "GxFilterFeatureClasses should work for featureClasses in the mdb and fdb, as well as the shapefiles."

I still don't know what that code works properly in another application. In subsequent testing, I found that other filters, such as  GxFilterPolygonFeatureClasses or GxFilterPointFeatureClasses, also don't ask for permission to overwrite files for shapefiles or geodatabase feature classes.
0 Kudos