<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Connect to Geodatabase Featureclass and/or shapefile in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614209#M16480</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Yes I was talking about Factory method pattern.&amp;nbsp; I was thinking something along those lines.&amp;nbsp; A class where you just pass a string in the constructor, no workspace factory, and it spit out the appropriate workspace.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;You would not want to pass a string, because that is not type safe.&amp;nbsp; What if someone passed in a misspelled string?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Feb 2013 17:51:00 GMT</pubDate>
    <dc:creator>LeoDonahue</dc:creator>
    <dc:date>2013-02-12T17:51:00Z</dc:date>
    <item>
      <title>Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614199#M16470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is probably very simple. I can load a geodatabase featureclass with IWorkspace::OpenFromFile and the FileGDBWorkspaceFactory CoClass and likewise with ShapefileWorkspaceFactoryClass for shapefiles...is there a way to load both with the same generic workspace factory or do I have to set a different one based on what is selected in my custom Add data dialog?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Gino&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2013 02:17:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614199#M16470</guid>
      <dc:creator>GinoMellino</dc:creator>
      <dc:date>2013-02-11T02:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614200#M16471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;This is probably very simple. I can load a geodatabase featureclass with IWorkspace::OpenFromFile and the FileGDBWorkspaceFactory CoClass and likewise with ShapefileWorkspaceFactoryClass for shapefiles...&lt;SPAN style="color:#0000ff;"&gt;&lt;STRONG&gt;is there a way to load both with the same generic workspace factory &lt;/STRONG&gt;&lt;/SPAN&gt;or do I have to set a different one based on what is selected in my custom Add data dialog?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is a generic workspace factory, it's called IWorkspaceFactory.&amp;nbsp; Many other concrete classes implement this Interface, such as the two types you mentioned.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2013 02:39:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614200#M16471</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2013-02-11T02:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614201#M16472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The interface is generic (IWorkspaceFactory) but the classes that implement it are all specific to the data type.&amp;nbsp; There isn't a workspaceFactory Factory class that creates the one you need based on the data type you input or that figures out the data type provided in the file path (.shp, .gdb or .sde.)&amp;nbsp; To make it would be easy but of limited value.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2013 16:45:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614201#M16472</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2013-02-11T16:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614202#M16473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The interface is generic (IWorkspaceFactory) but the classes that implement it are all specific to the data type.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;You are correct sir.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was being intentionally less obvious to the OP because I thought maybe they would see the difference between Interfaces and Classes and realize the answer to their question.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2013 18:08:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614202#M16473</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2013-02-11T18:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614203#M16474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You are correct sir.&lt;BR /&gt;&lt;BR /&gt;I was being intentionally less obvious to the OP because I thought maybe they would see the difference between Interfaces and Classes and realize the answer to their question.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I didn't mean your answer was incorrect or anything.&amp;nbsp; I just got thinking about the class factory design pattern, in which the factory class decides what type of object to create.&amp;nbsp; This is different from the workspace factory since you have to know what type of workspace you want (shapefile, file gdb, sde, etc.) before creating a specific type of workspace factory to get that same type of workspace.&amp;nbsp; It strikes me as somewhat going against what the factory design pattern is supposed to be.&amp;nbsp; Factories are supposed to decide the specific class type for you...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2013 18:20:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614203#M16474</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2013-02-11T18:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614204#M16475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all and thanks for the replies.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did recognise that IWorkspaceFactory was an interface but must apologise as I lack a good understanding of programming. I thought that there may be a generic coclass which implements IWorkspaceFactory which I could use. Thanks Alexander for clearing this up. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to use a GXDialog to add data of any kind to a map, which is why I need to be able to handle the user selecting Shapefile/GDB/SDE data sources. Is there a recommended way of handling these different types of data? Currently as a work around I test for the .shp extension to determine if its type.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again, Thanks for your help&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2013 21:58:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614204#M16475</guid>
      <dc:creator>GinoMellino</dc:creator>
      <dc:date>2013-02-11T21:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614205#M16476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There is a really cool thing called the ArcObjects API.&amp;nbsp; Granted, I can't hold it against anyone who tries to make sense of the ArcObjects .NET API, because you can't find anything without expanding, expanding, expanding.. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is a Java example, so sorry for that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I opened eclipse and used the new project wizard to create a console application.&amp;nbsp; Then I used the sample ArcGIS snippets for listing feature classes of a FGDB workspace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Notice in listFeatureclass, they use the concrete class FileGeodatabaseWorkspaceFactory to create new FileGeodatabaseWorkspaceFactory.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Notice in listFeatureclass2, we're using the WorkspaceFactory class&amp;nbsp; .. what?&amp;nbsp; What kind of black magic is that?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Give them a try, pass in a file name of "c:\\myfgdb.gdb" and see what happens.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void listFeatureclass(String file) throws java.net.UnknownHostException, java.io.IOException {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory factory = new com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IWorkspace workspace = factory.openFromFile(file, 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IEnumDataset enumDataset = workspace.getDatasets(com.esri.arcgis.geodatabase.esriDatasetType.esriDTFeatureClass);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IDataset ds = null;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ds = enumDataset.next();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(ds != null){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IFeatureClass fClass = new com.esri.arcgis.geodatabase.IFeatureClassProxy(ds);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int fCount = fClass.featureCount(null);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("FeatureClass "+ fClass.getAliasName() +" has "+fCount+ " features.");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ds = enumDataset.next();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void listFeatureclass2(String file) throws java.net.UnknownHostException, java.io.IOException {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.WorkspaceFactory factory = new com.esri.arcgis.geodatabase.WorkspaceFactory(new com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory());
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IWorkspace workspace = factory.openFromFile(file, 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IEnumDataset enumDataset = workspace.getDatasets(com.esri.arcgis.geodatabase.esriDatasetType.esriDTFeatureClass);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IDataset ds = null;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ds = enumDataset.next();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(ds != null){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IFeatureClass fClass = new com.esri.arcgis.geodatabase.IFeatureClassProxy(ds);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int fCount = fClass.featureCount(null);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("FeatureClass "+ fClass.getAliasName() +" has "+fCount+ " features.");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ds = enumDataset.next();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:16:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614205#M16476</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2021-12-12T02:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614206#M16477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;SPAN style="color:#0000ff;"&gt;&lt;STRONG&gt;I just got thinking about the class factory design pattern, in which the factory class decides what type of object to create.&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;nbsp; This is different from the workspace factory since you have to know what type of workspace you want (shapefile, file gdb, sde, etc.) before creating a specific type of workspace factory to get that same type of workspace.&amp;nbsp; It strikes me as somewhat going against what the factory design pattern is supposed to be.&amp;nbsp; Factories are supposed to decide the specific class type for you...&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you talking about the Factory Method pattern?&amp;nbsp; If yes, then you create an interface for creating objects, and let subclasses define what type of object is being created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could do something lame like this, but don't.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-size:2;"&gt;com.esri.arcgis.datasourcesfile.ShapefileWorkspaceFactory shp = new com.esri.arcgis.datasourcesfile.ShapefileWorkspaceFactory();&lt;BR /&gt;&lt;BR /&gt;com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory fgdb = new com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; createWorkspace("d:\\somefolder",shp,"someshapefilename");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; createWorkspace("d:\\somefolder\\somegeodatabase.gdb",fgdb,null);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void createWorkspace(String filePath, IWorkspaceFactory temp, String shapefileName){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(temp.getWorkspaceType() == esriWorkspaceType.esriFileSystemWorkspace){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.WorkspaceFactory wsf = new com.esri.arcgis.geodatabase.WorkspaceFactory(temp);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.Workspace work = new com.esri.arcgis.geodatabase.Workspace(wsf.openFromFile(filePath, 0));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IFeatureClass featureClass = work.openFeatureClass(shapefileName);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(featureClass.getAliasName() + " " + featureClass.featureCount(null));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(temp.getWorkspaceType() == esriWorkspaceType.esriLocalDatabaseWorkspace){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.WorkspaceFactory factory = new com.esri.arcgis.geodatabase.WorkspaceFactory(temp);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IWorkspace workspace = factory.openFromFile(filePath, 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IEnumDataset enumDataset = workspace.getDatasets(com.esri.arcgis.geodatabase.esriDatasetType.esriDTFeatureClass);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IDataset ds = null;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ds = enumDataset.next();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(ds != null){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IFeatureClass fClass = new com.esri.arcgis.geodatabase.IFeatureClassProxy(ds);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int fCount = fClass.featureCount(null);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(fClass.getAliasName() +" has "+fCount+ " features.");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ds = enumDataset.next();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (AutomationException e) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TODO Auto-generated catch block
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.printStackTrace();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (IOException e) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TODO Auto-generated catch block
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.printStackTrace();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:16:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614206#M16477</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2021-12-12T02:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614207#M16478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Are you talking about the Factory Method pattern?&amp;nbsp; If yes, then you create an interface for creating objects, and let subclasses define what type of object is being created.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes I was talking about Factory method pattern.&amp;nbsp; I was thinking something along those lines.&amp;nbsp; A class where you just pass a string in the constructor, no workspace factory, and it spit out the appropriate workspace. It seems like a recipe for trouble for not much gain.&amp;nbsp; I really don't feel like maintaining the code for every possible type of workspace including some that don't exist yet. Now if that sort of class was provided as part of the API, like an actual factory class, it would abstract a lot of the things you need to do and would reduce programmer error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WorkspaceFactory Class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; ctor workspaceStr&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Determine type of workspace needed&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create workspace factory for type&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; workspace property&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Open workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return workspace&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2013 16:43:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614207#M16478</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2013-02-12T16:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614209#M16480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Yes I was talking about Factory method pattern.&amp;nbsp; I was thinking something along those lines.&amp;nbsp; A class where you just pass a string in the constructor, no workspace factory, and it spit out the appropriate workspace.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;You would not want to pass a string, because that is not type safe.&amp;nbsp; What if someone passed in a misspelled string?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2013 17:51:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614209#M16480</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2013-02-12T17:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614210#M16481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You would not want to pass a string, because that is not type safe.&amp;nbsp; What if someone passed in a misspelled string?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Not a string containing the type, a string containing the path to the workspace.&amp;nbsp; Based on the type of string, *.gdb, *mdb,&amp;nbsp; *.sde etc. or the contents of the directory (info sub dir) or shapefiles, etc. the code decides which workspace factory is appropriate to instantiate.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2013 18:18:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614210#M16481</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2013-02-12T18:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614211#M16482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;right the constructor receives the string param that then decides what kind of workspace to create.&amp;nbsp; What if I passed in the string "taco"?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2013 18:33:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614211#M16482</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2013-02-12T18:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614212#M16483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well same as if you try openFromFile with string "taco" on a valid workspace factory.&amp;nbsp; In this case, failure just comes earlier.&amp;nbsp; The whole point is validating the string before you even create the workspace factory.&amp;nbsp;&amp;nbsp; In the process of trying to figure out the type of workspace there is a step that checks if it is a valid directory or file, if not throw an argument exception.&amp;nbsp; If after trying a bunch of combination, the code still can't figure out a valid workspace type, throw an argument exception.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2013 19:10:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614212#M16483</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2013-02-12T19:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614213#M16484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;But wouldn't you still want to pass an interface type to this factory method that decides how to return a workspace, rather than a string?&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is more than one esriWorkspaceType.esriFileSystemWorkspace, which could be shapefile, in memory, etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just as there is more than one type of esriWorkspaceType.esriLocalDatabaseWorkspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you declare a IWorkspaceFactory variable as a concrete type, then that type becomes the parameter for the WorkspaceFactory constructor.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2013 20:01:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614213#M16484</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2013-02-12T20:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614214#M16485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well the exercise would be fraught with danger of returning the wrong type of workspace but to pass in the type as a parameter negates the purpose.&amp;nbsp; Which is why I have never done it.&amp;nbsp; However it is done in esri code because the GxDialog returns IGxObjects that have an IName.&amp;nbsp; The IName allows you to open the item which means creating a workspace somewhere.&amp;nbsp; I just haven't quite figured out how to do it with the IGxObject and IGxObjectFactory (which is strongly typed.)&amp;nbsp; Somewhere in the GxDialog, it recognizes the file types on disc and it can later open by creating the appropriate workspace.&amp;nbsp; I think we have run off the original topic here.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2013 20:41:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614214#M16485</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2013-02-12T20:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614215#M16486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;....&lt;BR /&gt;&lt;BR /&gt;This is a Java example, so sorry for that.&lt;BR /&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ha! No need to ever apologize for using Java. Thanks for these great discussions.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Feb 2013 14:33:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614215#M16486</guid>
      <dc:creator>EricBader</dc:creator>
      <dc:date>2013-02-16T14:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to Geodatabase Featureclass and/or shapefile</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614208#M16479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;There is a really cool thing called the ArcObjects API.&amp;nbsp; Granted, I can't hold it against anyone who tries to make sense of the ArcObjects .NET API, because you can't find anything without expanding, expanding, expanding.. &lt;BR /&gt;&lt;BR /&gt;This is a Java example, so sorry for that.&lt;BR /&gt;&lt;BR /&gt;I opened eclipse and used the new project wizard to create a console application.&amp;nbsp; Then I used the sample ArcGIS snippets for listing feature classes of a FGDB workspace.&lt;BR /&gt;&lt;BR /&gt;Notice in listFeatureclass, they use the concrete class FileGeodatabaseWorkspaceFactory to create new FileGeodatabaseWorkspaceFactory.&lt;BR /&gt;&lt;BR /&gt;Notice in listFeatureclass2, we're using the WorkspaceFactory class&amp;nbsp; .. what?&amp;nbsp; What kind of black magic is that?&lt;BR /&gt;&lt;BR /&gt;Give them a try, pass in a file name of "c:\\myfgdb.gdb" and see what happens.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void listFeatureclass(String file) throws java.net.UnknownHostException, java.io.IOException {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory factory = new com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IWorkspace workspace = factory.openFromFile(file, 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IEnumDataset enumDataset = workspace.getDatasets(com.esri.arcgis.geodatabase.esriDatasetType.esriDTFeatureClass);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IDataset ds = null;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ds = enumDataset.next();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(ds != null){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IFeatureClass fClass = new com.esri.arcgis.geodatabase.IFeatureClassProxy(ds);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int fCount = fClass.featureCount(null);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("FeatureClass "+ fClass.getAliasName() +" has "+fCount+ " features.");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ds = enumDataset.next();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void listFeatureclass2(String file) throws java.net.UnknownHostException, java.io.IOException {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.WorkspaceFactory factory = new com.esri.arcgis.geodatabase.WorkspaceFactory(new com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory());
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IWorkspace workspace = factory.openFromFile(file, 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IEnumDataset enumDataset = workspace.getDatasets(com.esri.arcgis.geodatabase.esriDatasetType.esriDTFeatureClass);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IDataset ds = null;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ds = enumDataset.next();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(ds != null){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.esri.arcgis.geodatabase.IFeatureClass fClass = new com.esri.arcgis.geodatabase.IFeatureClassProxy(ds);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int fCount = fClass.featureCount(null);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("FeatureClass "+ fClass.getAliasName() +" has "+fCount+ " features.");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ds = enumDataset.next();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That is really interesting, Java is very different when it comes to that sort of thing.&amp;nbsp; You can't do that in .NET, the constructor for workspacefactory is not accessible outside the its own assembly.&amp;nbsp;&amp;nbsp; Typically in .NET you don't declare an object as a class, always an interface&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;even if you know the exact type of class to which you have a reference, the .NET runtime still does not have the required metadata to cast the variable to a strongly typed RCW&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000151000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000151000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:16:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/connect-to-geodatabase-featureclass-and-or/m-p/614208#M16479</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2021-12-12T02:16:30Z</dc:date>
    </item>
  </channel>
</rss>

