<?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: IWorkspace.PathName returns empty string in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspace-pathname-returns-empty-string/m-p/291739#M7592</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry for the confusion - I mentioned other users (ie. users in other threads, not users of my code) had experienced the same issue with SDE database feature classes, but I'm only using PGDB feature classes and tables. However, you may be on to something regarding the explicit cast of the IDataset to a ESRI.ArcGIS.Geodatabase.IDataset. I'll give this a try.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;James&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Oct 2011 09:39:23 GMT</pubDate>
    <dc:creator>JamesLanyon</dc:creator>
    <dc:date>2011-10-24T09:39:23Z</dc:date>
    <item>
      <title>IWorkspace.PathName returns empty string</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspace-pathname-returns-empty-string/m-p/291734#M7587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a frustrating unpredictable situation where for some reason (which I have yet discovered the reason) when I call &lt;/SPAN&gt;&lt;STRONG&gt;IWorkspace.PathName&lt;/STRONG&gt;&lt;SPAN&gt; I get an empty string. I am solely dealing with personal GDB feature classes - no remote database workspaces involved. I initially thought it was down to the fact that I had a large number of layers loaded in my TOC all located in my PGDB, so removed all of the unnecessary layers before calling the code. This appears to sort the problem for 99% of the time, but hasn't solved it completely. I'm running 9.3 on XP (32 and 64-bit) and get the empty string returned on both platforms. I've noticed users finding this occurring with SDE databases but not with PGDBs - has anyone experienced this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;James&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2011 15:28:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspace-pathname-returns-empty-string/m-p/291734#M7587</guid>
      <dc:creator>JamesLanyon</dc:creator>
      <dc:date>2011-10-12T15:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspace.PathName returns empty string</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspace-pathname-returns-empty-string/m-p/291735#M7588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have a frustrating unpredictable situation where for some reason (which I have yet discovered the reason) when I call &lt;STRONG&gt;IWorkspace.PathName&lt;/STRONG&gt; I get an empty string. I am solely dealing with personal GDB feature classes - no remote database workspaces involved. I initially thought it was down to the fact that I had a large number of layers loaded in my TOC all located in my PGDB, so removed all of the unnecessary layers before calling the code. This appears to sort the problem for 99% of the time, but hasn't solved it completely. I'm running 9.3 on XP (32 and 64-bit) and get the empty string returned on both platforms. I've noticed users finding this occurring with SDE databases but not with PGDBs - has anyone experienced this?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;James&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;James,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How are you going thru the list of layers in the TOC?&amp;nbsp; This is just a hunch, but are you accounting for the zero-based index count?&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
For i = 0 To pMap.LayerCount - 1
&amp;nbsp; 'get the pathName of the pMap.Layer(i)
Next
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this would start at the first layer and end at the last one.&amp;nbsp; If you didn't specify -1 on the layerCount, it could potentially sequence to a nothing for the layer and return an null/empty string or throwing an ArgumnetExeption -- and depending upon how you are handling the error it might be the cause of the empty null being returned.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Post up some of the code you suspect is giving the problems.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:03:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspace-pathname-returns-empty-string/m-p/291735#M7588</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T14:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspace.PathName returns empty string</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspace-pathname-returns-empty-string/m-p/291736#M7589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Also, I just found this in the documentation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"...If an SDE workspace was created from a PropertySet, PathName will be empty"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See here: &lt;/SPAN&gt;&lt;A href="http://edndoc.esri.com/arcobjects/9.0/componenthelp/esriGeodatabase/IWorkspace_PathName.htm"&gt;http://edndoc.esri.com/arcobjects/9.0/componenthelp/esriGeodatabase/IWorkspace_PathName.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2011 16:13:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspace-pathname-returns-empty-string/m-p/291736#M7589</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2011-10-12T16:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspace.PathName returns empty string</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspace-pathname-returns-empty-string/m-p/291737#M7590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi James,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for replying to my post - the code that returns an empty string doesn't involve a loop through the layers in the TOC, I'm using this property to get the full file path to my featureclass by simply casting the featureclass as an IDataset and then getting the Workspace.PathName property from this, ie.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pDataset as IDataset&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pDataset = pFeatureClass&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pWorkspace as IWorkspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pWorkspace = pDataset.Workspace 'This does not get set to Nothing&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim sPath as String&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sPath = pWorkspace.PathName 'This returns an empty string even though pWorkspace is set&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The feature class is a personal geodatabase featureclass, I'm not dealing with SDE featureclasses so unfortunately your second post doesn't apply, but thanks for looking into this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;James&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 07:42:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspace-pathname-returns-empty-string/m-p/291737#M7590</guid>
      <dc:creator>JamesLanyon</dc:creator>
      <dc:date>2011-10-18T07:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspace.PathName returns empty string</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspace-pathname-returns-empty-string/m-p/291738#M7591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;The feature class is a personal geodatabase featureclass, I'm not dealing with SDE featureclasses so unfortunately your second post doesn't apply, but thanks for looking into this.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But from your original post you say that this occurs with SDE FeatureClasses...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]&lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;"...I've noticed users finding this occurring with SDE databases but not with PGDBs - has anyone experienced this?"&lt;/SPAN&gt;&lt;SPAN&gt;[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wonder if the issue is that because you have a large number of layers in the TOC that something isn't slipping by you that you think is something else (like an SDE FC or something and is the one that is causing problems).&amp;nbsp; In which case you might want to check/verify the type prior to checking it's path.&amp;nbsp; The help has an example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Public Function GetPathForALayer(ByVal layer As ESRI.ArcGIS.Carto.ILayer) As System.String

If layer Is Nothing OrElse Not (TypeOf layer Is ESRI.ArcGIS.Geodatabase.IDataset) Then
&amp;nbsp; Return Nothing
End If

Dim dataset As ESRI.ArcGIS.Geodatabase.IDataset = CType(layer, ESRI.ArcGIS.Geodatabase.IDataset) ' Explicit Cast

Return (dataset.Workspace.PathName &amp;amp; "\" &amp;amp; dataset.Name)

End Function
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Get_Path_for_a_Layer_Snippet/004900000092000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Get_Path_for_a_Layer_Snippet/004900000092000000/&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:03:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspace-pathname-returns-empty-string/m-p/291738#M7591</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T14:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspace.PathName returns empty string</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspace-pathname-returns-empty-string/m-p/291739#M7592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry for the confusion - I mentioned other users (ie. users in other threads, not users of my code) had experienced the same issue with SDE database feature classes, but I'm only using PGDB feature classes and tables. However, you may be on to something regarding the explicit cast of the IDataset to a ESRI.ArcGIS.Geodatabase.IDataset. I'll give this a try.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;James&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Oct 2011 09:39:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspace-pathname-returns-empty-string/m-p/291739#M7592</guid>
      <dc:creator>JamesLanyon</dc:creator>
      <dc:date>2011-10-24T09:39:23Z</dc:date>
    </item>
  </channel>
</rss>

