<?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: IWorkspaceFactory deletes all features in original database in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355806#M9410</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Duncan,&amp;nbsp; I hadn't really considered that.&amp;nbsp; I am more of an AO monkey.&amp;nbsp; I still shudder at how bad the GP was in early 9.x versions.&amp;nbsp; I was also worried that the lock files might cause problems.&amp;nbsp; If I did that I wouldn't have to do synchronously (not a bad thing.)&amp;nbsp; I put the file copy change into the staging environment, if it passes regression and UAT and makes into prod, I will let sleeping dogs lie, if not I will give that a go.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Aug 2013 16:47:25 GMT</pubDate>
    <dc:creator>AlexanderGray</dc:creator>
    <dc:date>2013-08-14T16:47:25Z</dc:date>
    <item>
      <title>IWorkspaceFactory deletes all features in original database</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355802#M9406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Another fun intermittant problem...&amp;nbsp; I have a system requirement to make a full back-up of a gdb before doing some crunching on it to make sure to be able to back-out if something nasty happens.&amp;nbsp; Turns out the back-up I do is causing something nasty&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim wkspcFact As IWorkspaceFactory = New FileGDBWorkspaceFactory 'I later changed this use activator (no difference)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim copyWsName As IWorkspaceName = Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp; wkspcFact.Copy(CType(dsWork.FullName, IWorkspaceName), IO.Path.GetDirectoryName(candidateFullPath), copyWsName)

&amp;nbsp;&amp;nbsp;&amp;nbsp; Trace.WriteLine("copy workspace done to " &amp;amp; copyWsName.BrowseName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim copyWkDS As IDataset = DirectCast(DirectCast(copyWsName, IName).Open, IDataset)
&amp;nbsp;&amp;nbsp;&amp;nbsp; If copyWkDS.CanRename() Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; copyWkDS.Rename(IO.Path.GetFileName(candidateFullPath))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Trace.WriteLine("Rename to : " &amp;amp; candidateFullPath)
&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code is called from arcmap during an edit session.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem that some times happens is that the copy goes smoothly and the back-up is fine but all the features in the original are gone.&amp;nbsp; Using featurecount on the featureclasses return the correct count but using gp tools report the feature classes as empty as they appear to be in arcmap.&amp;nbsp; Restarting the edit session still reports the original number of features in the feature classes even if they are empty.&amp;nbsp; If I restart ArcMap, the feature count is zero.&amp;nbsp; ArcCatalog also report a feature count of zero.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I replace the above code with this much less elegant code that seems to work better.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp; Dim SourcePath As String = workspace.PathName
&amp;nbsp;&amp;nbsp;&amp;nbsp; IO.Directory.CreateDirectory(candidateFullPath)
&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each dirPath As String In IO.Directory.GetDirectories(SourcePath, "*", IO.SearchOption.AllDirectories)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IO.Directory.CreateDirectory(dirPath.Replace(SourcePath, candidateFullPath))
&amp;nbsp;&amp;nbsp;&amp;nbsp; Next


&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each newPath As String In IO.Directory.GetFiles(SourcePath, "*.*", IO.SearchOption.AllDirectories)
&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; 'if the file has a lock on it, as lock files do, it will fail to copy.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'the prefered workspace copy is causing bigger problems than this.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If String.Compare(IO.Path.GetExtension(newPath), ".lock", True) &amp;lt;&amp;gt; 0 Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IO.File.Copy(newPath, newPath.Replace(SourcePath, candidateFullPath), True)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Catch ex As Exception
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Trace.WriteLine(ex)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Trace.WriteLine(newPath)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Try
&amp;nbsp;&amp;nbsp;&amp;nbsp; Next
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 14:44:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355802#M9406</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2013-08-06T14:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspaceFactory deletes all features in original database</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355803#M9407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Copying a database isn't something I would do while inside an edit session started on that database.&amp;nbsp; Have you tried it outside of the edit session?&amp;nbsp; Also, in VB.NET you can use My.Computer.FileSystem.CopyDirectory to copy the database folder and all of its contents to a new location.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 17:29:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355803#M9407</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2013-08-06T17:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspaceFactory deletes all features in original database</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355804#M9408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Copying a database isn't something I would do while inside an edit session started on that database.&amp;nbsp; Have you tried it outside of the edit session?&amp;nbsp; Also, in VB.NET you can use My.Computer.FileSystem.CopyDirectory to copy the database folder and all of its contents to a new location.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; Thanks Neil,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes I tried calling stopediting(true) before the backup also but I still got the same sort of problems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hesitate to use My.Computer.FileSystem.CopyDirectory because of the exception handling of exceptions on individual files.&amp;nbsp; Also I can't filter out the schema lock files that way.&amp;nbsp; The reason I wanted to use the workspace factory copy was that esri would presumably handle the lock files and future files that don't yet exist in geodatabase.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 13:03:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355804#M9408</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2013-08-07T13:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspaceFactory deletes all features in original database</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355805#M9409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alexander,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just an idea but have you tried calling the Copy geo-processing tool to copy the workspace?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2013 13:00:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355805#M9409</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2013-08-14T13:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspaceFactory deletes all features in original database</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355806#M9410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Duncan,&amp;nbsp; I hadn't really considered that.&amp;nbsp; I am more of an AO monkey.&amp;nbsp; I still shudder at how bad the GP was in early 9.x versions.&amp;nbsp; I was also worried that the lock files might cause problems.&amp;nbsp; If I did that I wouldn't have to do synchronously (not a bad thing.)&amp;nbsp; I put the file copy change into the staging environment, if it passes regression and UAT and makes into prod, I will let sleeping dogs lie, if not I will give that a go.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2013 16:47:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355806#M9410</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2013-08-14T16:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspaceFactory deletes all features in original database</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355807#M9411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Speaking to Java:&amp;nbsp; Calling geoprocessing tools in ArcObjects, using Add-ins, have side effects.&amp;nbsp; Your TOC and Data view are always updating, flashing during those GP routines.&amp;nbsp; I have to remember not to call map.refresh when using GP tools in Add-ins.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2013 17:03:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355807#M9411</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2013-08-14T17:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: IWorkspaceFactory deletes all features in original database</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355808#M9412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ah yeah, I don't use java, I use .net.&amp;nbsp;&amp;nbsp; This project started at 9.3 and is a little too complicated for addins...&amp;nbsp; I find a lot of the flakiness with the com interop for .net, I assume it is the same for java.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2013 18:08:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/iworkspacefactory-deletes-all-features-in-original/m-p/355808#M9412</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2013-08-14T18:08:05Z</dc:date>
    </item>
  </channel>
</rss>

