Create a temporary directory
I've had a few cases where in a server workflow, I needed to create a zip file of a number of files. Because the zip activity takes a directory as input, I first need to save those files somewhere temporarily. Another case was when I needed to store some PDF's somewhere, in order to merge them (although Merge PDF's also takes byte[] as input).
The only way I found to get a temporary directory is to hardcode some base path, say C:\Temp, and create a subfolder based on a random number from Get Random Value. While this would work fine in most cases, I don't like having hardcoded paths in workflows, and the random number feels a bit like a kludge.
I'd like to propose a new activity that creates and returns a new (temporary) directory, which is also deleted at some point, maybe after the workflow finishes, or maybe similar to how Create Download expires.
-
That's an interesting idea. We do create temporary files/directories in certain activities. (I think Run Python for one.) It could be plausible to do something similar in isolation.
It'd need to be .NET only. (Probably Workflow Server only, not sure about Mobile or Desktop.) I imagine creating something under %TEMP% and then the activity output being the directory path.
There's a Path.GetTempFileName method that we use in some cases to get a unique name, delete the file and then create a directory by the same name. It's under %TEMP% so Windows can potentially clean it up later.
0 -
Yes, that's exactly what I had in mind. I had only thought about server workflows, but now that you mention it, I don't see any reason not to have it in Mobile as well. AFAIK Path.GetTempFileName works in UWP too, and otherwise there is ApplicationData.Current.TemporaryFolder
0
Please sign in to leave a comment.
Comments
2 comments