Where to Write Temporary XML Files

262
3
Jump to solution
10-12-2012 04:00 PM
RandyKreuziger
Regular Contributor
I'm creating a tool to edit metadata.  The tool will export a feature class's metadata as an XML file, make modification to the file then import it back in.  Where is a safe place for tools to create temporary text and XML files?
0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Esteemed Contributor
I wrote some tools along these lines, and used Windows TEMP.

In ModelBuilder, I got the path from the system environment variable TEMP using the Calculate Value tool. Set the output data type to Folder.

Expression: env("TEMP")

Code Block:
def env(envVar):   import os   return os.environ[envVar]


If you're python scripting, just use os.environ

tmpXML = os.environ["TEMP"] + "/" + "xxtemp.xml"

View solution in original post

0 Kudos
3 Replies
DaleHoneycutt
Regular Contributor
If you're using 10.1, you can use the ScratchFolder environment value
0 Kudos
curtvprice
MVP Esteemed Contributor
I wrote some tools along these lines, and used Windows TEMP.

In ModelBuilder, I got the path from the system environment variable TEMP using the Calculate Value tool. Set the output data type to Folder.

Expression: env("TEMP")

Code Block:
def env(envVar):   import os   return os.environ[envVar]


If you're python scripting, just use os.environ

tmpXML = os.environ["TEMP"] + "/" + "xxtemp.xml"
0 Kudos
RandyKreuziger
Regular Contributor
Thanks for the solutions.  I tried to mark both your posts as answering the question but the system won't allow it :(
0 Kudos