<?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 Temporary raster - what if TEMP/TMP is readonly? in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/temporary-raster-what-if-temp-tmp-is-readonly/m-p/178999#M4627</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm developing a tool in VB.Net that involves some raster processing using temporary datasets for the intermediate steps.&amp;nbsp; Typically, ArcMap does this by storing the temporary rasters in the folder specified by the system TEMP or TMP variables.&amp;nbsp; These temporary rasters go away automatically when they are no longer referenced or when I release the objects in code.&amp;nbsp; Everything works perfectly fine according to ArcObjects documentation.&amp;nbsp; That is, unless the value of TEMP/TMP points to a folder that is not writeable by the user.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, I have a user with TEMP/TMP set to "C:\Program Files\ArcGIS\Bin" (which I'd advise against, but that's a different story).&amp;nbsp; When the user runs my tool, ArcMap cannot save the temp rasters to that location and the tool crashes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a better way to handle temporary rasters?&amp;nbsp; I've seen some sample code that uses a hardcoded "C:\temp" location, but I don't think that's the best practice either.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for your help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Keith&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Jun 2011 22:20:52 GMT</pubDate>
    <dc:creator>KeithOlson</dc:creator>
    <dc:date>2011-06-20T22:20:52Z</dc:date>
    <item>
      <title>Temporary raster - what if TEMP/TMP is readonly?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/temporary-raster-what-if-temp-tmp-is-readonly/m-p/178999#M4627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm developing a tool in VB.Net that involves some raster processing using temporary datasets for the intermediate steps.&amp;nbsp; Typically, ArcMap does this by storing the temporary rasters in the folder specified by the system TEMP or TMP variables.&amp;nbsp; These temporary rasters go away automatically when they are no longer referenced or when I release the objects in code.&amp;nbsp; Everything works perfectly fine according to ArcObjects documentation.&amp;nbsp; That is, unless the value of TEMP/TMP points to a folder that is not writeable by the user.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, I have a user with TEMP/TMP set to "C:\Program Files\ArcGIS\Bin" (which I'd advise against, but that's a different story).&amp;nbsp; When the user runs my tool, ArcMap cannot save the temp rasters to that location and the tool crashes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a better way to handle temporary rasters?&amp;nbsp; I've seen some sample code that uses a hardcoded "C:\temp" location, but I don't think that's the best practice either.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for your help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Keith&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2011 22:20:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/temporary-raster-what-if-temp-tmp-is-readonly/m-p/178999#M4627</guid>
      <dc:creator>KeithOlson</dc:creator>
      <dc:date>2011-06-20T22:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Temporary raster - what if TEMP/TMP is readonly?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/temporary-raster-what-if-temp-tmp-is-readonly/m-p/179000#M4628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;After some more digging, I found out that the user does have the TEMP variable set to a writeable folder.&amp;nbsp; However, the error message they get includes this: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;System.Runtime.InteropServices.COMException: ("esriDataSourcesRaster.GdalDriver") Failed to copy raster dataset &lt;BR /&gt;ERROR 010240: Could not save raster dataset to C:\Program Files\ArcGIS\Desktop10.0\Bin\C:\Program Files\ArcGIS\Desktop10.0\Bin\ras44 with output format GRID.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, why would it be trying to save to that location if the TEMP variable points to a different location?&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(Also, strange error message with the duplicated folder path.&amp;nbsp; Not sure what the deal is there...)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway, here's the piece of code that leads to the exception:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Dim pClipDataset As IGeoDataset = Nothing
Dim pTransOp As ITransformationOp = New RasterTransformationOp
Dim pEnv as IEnvelope = New Envelope
pEnv.PutCoords(pUTM_xmin, pUTM_ymin, pUTM_xmax, pUTM_ymax)&amp;nbsp;&amp;nbsp; 'variable values set earlier
pClipDataset = pTransOp.Clip(CType(pSelectedRaster.Raster, IGeoDataset), pEnv)&amp;nbsp; 'pSelectedRaster is an IRasterLayer object defined earlier
&lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again for most users this works just fine.&amp;nbsp; But for the one user it fails and gives the error above.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:10:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/temporary-raster-what-if-temp-tmp-is-readonly/m-p/179000#M4628</guid>
      <dc:creator>KeithOlson</dc:creator>
      <dc:date>2021-12-11T09:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: Temporary raster - what if TEMP/TMP is readonly?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/temporary-raster-what-if-temp-tmp-is-readonly/m-p/179001#M4629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Update: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The user has been able to get the tool to work on their machine with other input rasters.&amp;nbsp; So, we are chalking this one up as something quirky going on with that one raster.&amp;nbsp; The unsettling thing is that we cannot reproduce the error on any other machine even using the raster in question.&amp;nbsp; We're putting this one to bed for now and moving forward, but if anyone has any other ideas or plausable explanations, it would still be appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2011 16:17:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/temporary-raster-what-if-temp-tmp-is-readonly/m-p/179001#M4629</guid>
      <dc:creator>KeithOlson</dc:creator>
      <dc:date>2011-06-22T16:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Temporary raster - what if TEMP/TMP is readonly?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/temporary-raster-what-if-temp-tmp-is-readonly/m-p/179002#M4630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In my VB.NET application, I've used a scratch workspace to store the temporary files. &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Creating_geodatabases/0001000004t8000000/"&gt;Here&lt;/A&gt;&lt;SPAN&gt;'s the help information about creating them.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jun 2011 14:35:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/temporary-raster-what-if-temp-tmp-is-readonly/m-p/179002#M4630</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2011-06-23T14:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: Temporary raster - what if TEMP/TMP is readonly?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/temporary-raster-what-if-temp-tmp-is-readonly/m-p/179003#M4631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ken, thanks for that link.&amp;nbsp; Next time we generate a new build, I'll look into that some more.&amp;nbsp; Might be worth a try and perhaps better than messing with the system variable.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jun 2011 18:05:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/temporary-raster-what-if-temp-tmp-is-readonly/m-p/179003#M4631</guid>
      <dc:creator>KeithOlson</dc:creator>
      <dc:date>2011-06-23T18:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Temporary raster - what if TEMP/TMP is readonly?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/temporary-raster-what-if-temp-tmp-is-readonly/m-p/179004#M4632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Finally solved this one.&amp;nbsp; For anyone interested, we actually discovered that the problem was due to the user's regular temp space (C:\Users\&amp;lt;username&amp;gt;\AppData\Local\Temp) being filled up.&amp;nbsp; ArcGIS uses the same temp folder as many other applications, so if proper garbage collection is not performed or if apps using that temp space crash, etc. the temp files get left behind.&amp;nbsp; Over time the folder will fill up to its allocated limit.&amp;nbsp; When this happens, ArcMap detects that the folder is full and moves on to the next location it thinks might be good to store temp files, which in our case was in C:\Program Files... which the user is not allowed to write to.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We had the user manually empty his temp folder and then the tool ran successfully.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, our solution then was to catch the exception and give the user a message that his temp folder is full and that they need to delete files there before proceeding.&amp;nbsp; We also noticed that ArcMap does not delete scratch workspaces upon exit like it does other temp data, so we went ahead and added code to delete all scratch workspace files when the tool is finished.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2012 16:29:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/temporary-raster-what-if-temp-tmp-is-readonly/m-p/179004#M4632</guid>
      <dc:creator>KeithOlson</dc:creator>
      <dc:date>2012-09-12T16:29:15Z</dc:date>
    </item>
  </channel>
</rss>

