How to get path of default scratch workspace(folder) using c#?
I'm making REST GP tool, where you pass some input parameters, tool collects data, create csv files, and archive them. Then tool return path to archive file.
Tool logic is done, but i'm stuck on where to write files(and how to return path), and thought, that scratch folder would be good choice for that. In python I would do something like:
%scratchFolder%\....
or
arcpy.env.scratchFolder
But that doesn't work in C#. Any suggestions?
EDIT:
Thanks, it was really that simple in the end
IScratchWorkspaceFactory scratchWsF = new ScratchWorkspaceFactory();
IWorkspace sWS = scratchWsF.DefaultScratchWorkspace;
string scratchWS = System.IO.Path.GetDirectoryName(sWS.PathName)+"\\";
EDIT 2: The previous solution works fine for GP tool and returns smth like "C:\Users\Admin\AppData\Local\Temp\arc161B...", but for GP REST service that does not work:
IScratchWorkspaceFactory2 scratchWsF = new ScratchWorkspaceFactory()
as IScratchWorkspaceFactory2;
//and
IScratchWorkspaceFactory scratchWsF = new ScratchWorkspaceFactory();
stops the execute method, without any error if used in published GP service(but works in GP tool). Recently found out, that every instance of GP service have its own scrach, but i am unable to find a way to get to that.
activator.createinstanceas recommended in the help doc? – Kirk Kuykendall Nov 16 '12 at 13:44