Creating a temporary directory in Windows?

No, there is no equivalent to mkdtemp. The best option is to use a combination of GetTempPath and GetRandomFileName. You would need code similar to this: public string GetTemporaryDirectory() { string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); Directory.CreateDirectory(tempDirectory); return tempDirectory; }

How to get temporary folder for current user

System.IO.Path.GetTempPath() is just a wrapper for a native call to GetTempPath(..) in Kernel32. Have a look at http://msdn.microsoft.com/en-us/library/aa364992(VS.85).aspx Copied from that page: The GetTempPath function checks for the existence of environment variables in the following order and uses the first path found: The path specified by the TMP environment variable. The path specified by the … Read more

How to create a temporary directory/folder in Java?

If you are using JDK 7 use the new Files.createTempDirectory class to create the temporary directory. Path tempDirWithPrefix = Files.createTempDirectory(prefix); Before JDK 7 this should do it: public static File createTempDirectory() throws IOException { final File temp; temp = File.createTempFile(“temp”, Long.toString(System.nanoTime())); if(!(temp.delete())) { throw new IOException(“Could not delete temp file: ” + temp.getAbsolutePath()); } if(!(temp.mkdir())) … Read more